Mastering Windows Automation with AHK 2.0
By John Nunez
()
About this ebook
Unlock the full potential of your Windows experience with "Mastering Windows Automation with AHK 2.0." This comprehensive guide, authored by John Nunez, delves into the power and versatility of AutoHotkey (AHK) version 2.0, providing you with the tools and knowledge needed to automate repetitive tasks, enhance productivity, and create customized solutions tailored to your needs.
Highlights:
Introduction to AutoHotkey v 2.0:Explore the history and evolution of AutoHotkey, from its inception in 2003 to the robust, user-friendly AHK 2.0.
Discover key features such as simplified syntax, enhanced performance, improved error handling, and expanded functionality.
Learn about the various applications of AHK, including task automation, custom keyboard shortcuts, system administration, gaming enhancements, and accessibility solutions.
Getting Started with AHK 2.0:Step-by-step instructions on downloading, installing, and configuring AHK 2.0 on your computer.
Create and run your first script, manage scripts through the system tray, and access help and documentation.
Quick Start with AHK v 2.0:
Master the basics of hotkeys, hotstrings, sending keystrokes, running programs and websites, and using variables and objects.
Tons of hands-on examples and practical exercises to solidify your understanding and skills.
The AutoHotkey v 2.0.0 Dashboard:Navigate the AHK Dashboard, a user-friendly interface for creating, editing, running, and managing scripts.Utilize tools such as the script editor, window spy, script compiler, and access to extensive documentation and community support.
The Window Spy Utility:Learn how to use the Window Spy utility
Implement practical examples to interact with specific windows and automate complex tasks.
Variables & Arrays Explained: Comprehensive coverage of variables, including clearing, retrieving, and assigning values, as well as using boolean values and handling special characters.
Explore arrays and objects for efficient data management, with practical examples like managing a to-do list.
Hotkeys - Modifier Symbols:Define and use hotkeys with modifier symbols for complex and context-sensitive actions.
Learn the intricacies of sending keystrokes and key combinations, including advanced usage tips for error handling and script efficiency.
Managing Windows:
Master window management techniques, including opening, moving, and interacting with windows using AHK scripts.
Advanced examples for handling multiple windows, interacting with controls, and customizing window styles.
Basic and Advanced Object-Oriented Programming:
Grasp the fundamentals of object-oriented programming (OOP) in AHK, including creating classes, inheritance, encapsulation, and polymorphism.
Implement practical OOP examples to manage complex automation tasks efficiently.
GUI Objects:
Create and manage graphical user interfaces (GUIs) with AHK, including setting window options, handling events, and modifying appearances.
Practical examples to build interactive and user-friendly GUIs for your scripts.
AHK Keys for the Keyboard, Mouse, and Controller:
Extend your automation capabilities to include keyboard, mouse, and game controller interactions.
Detailed examples to integrate these inputs into your scripts seamlessly.
Compiling an AHK Script:
Learn to compile your AHK scripts into standalone executables for easy distribution and execution without requiring AHK installation.
AHK v 2.0 Weekly Bootcamp:
Structured bootcamp program to accelerate your learning, covering essential topics over a week with expanded sessions for in-depth exploration.
Read more from John Nunez
GUI Magic: Mastering Real Projects in Python Rating: 0 out of 5 stars0 ratingsRemedios del Pasado: Un Viaje a la Medicina Antigua Rating: 0 out of 5 stars0 ratingsThe Modern Leader's Guide: Reimagining Machiavelli's 'The Prince' Rating: 0 out of 5 stars0 ratingsStocks Trading Secrets: Mastering Day Trading Rating: 0 out of 5 stars0 ratingsMind Your Gut: The Science Behind the Gut-Brain Axis Rating: 0 out of 5 stars0 ratingsBeyond the Blank Page: Design Limitless Worlds With AI Rating: 0 out of 5 stars0 ratingsThe Gut Health Revolution Rating: 5 out of 5 stars5/5Veiled Valor: The Chameleon's War Rating: 0 out of 5 stars0 ratingsUnlock Your Energy: Natural Ways to Fuel Your Body Rating: 0 out of 5 stars0 ratingsThe Stock Market from A to See - 2nd Edition Rating: 0 out of 5 stars0 ratingsAnybody Can Make Money in the Stock Market Rating: 0 out of 5 stars0 ratingsSmart Workspaces: The Power of AI in Office Automation Rating: 0 out of 5 stars0 ratingsAfraid of AI? Let Me Teach You How to Work with ChatGPT Rating: 0 out of 5 stars0 ratingsTeaching Scratch Programming…from Scratch Rating: 0 out of 5 stars0 ratingsAlzheimer's: Early Detection Workbook Rating: 0 out of 5 stars0 ratingsThe Ancient Medicine Cabinet Rating: 0 out of 5 stars0 ratingsThe Legend of Tatsuya: guardian of the Four Winds Rating: 0 out of 5 stars0 ratingsAI: Teach me How to Write a Book - 2nd Edition Rating: 0 out of 5 stars0 ratings
Related to Mastering Windows Automation with AHK 2.0
Related ebooks
AutoHotkey Tricks You Ought To Do With Windows Rating: 5 out of 5 stars5/5COMPUTER PRODUCTIVITY BOOK 1 Use AutoHotKey Create your own personal productivity scripts: AutoHotKey productivity, #1 Rating: 0 out of 5 stars0 ratingsAutoHotKey Computer Productivity Book 0: AutoHotKey productivity, #0 Rating: 0 out of 5 stars0 ratingsComputer Productivity Book 2. Use AutoHotKey to Share your Personal Productivity Scripts: AutoHotKey productivity, #2 Rating: 0 out of 5 stars0 ratingsWhy AutoHotkey? How Free AutoHotkey Adds Power to Your Windows PC and Provides You Important Brain Food Rating: 5 out of 5 stars5/5Tech Ninja Tactics The Windows + R Command Playbook Rating: 0 out of 5 stars0 ratingsWindows 7 Rating: 0 out of 5 stars0 ratingsMicrosoft Skype For Business 2016 Keyboard Shortcuts for Windows Rating: 0 out of 5 stars0 ratingsThe Windows Command Line Beginner's Guide: Second Edition Rating: 4 out of 5 stars4/5Learn Batch File Programming! Rating: 1 out of 5 stars1/5Troubleshooting and Maintaining Your PC All-in-One For Dummies Rating: 5 out of 5 stars5/5Windows Batch File Programming Rating: 2 out of 5 stars2/5Microsoft PowerShell, VBScript and JScript Bible Rating: 0 out of 5 stars0 ratingsAUTOMATING REVIT 1: Create- Simple Scripts for Beginners to Speed up your REVIT Productivity: Automating Revit, #1 Rating: 0 out of 5 stars0 ratingsMastering AWK Programming: From Basics to Expert Proficiency Rating: 0 out of 5 stars0 ratingsBash Mastery: From Command Line Basics to Automation Powerhouse Rating: 0 out of 5 stars0 ratingsWindows Server 2022 & PowerShell All-in-One For Dummies Rating: 0 out of 5 stars0 ratingsWindows 7 For Dummies Rating: 4 out of 5 stars4/5Let's Use Bash on Windows 10! The Lite version Rating: 0 out of 5 stars0 ratingsWindows 10 – Complete guide book to use your PC more efficiently Rating: 0 out of 5 stars0 ratingsMastering Bash: From Basics to Advanced Shell Scripting Rating: 0 out of 5 stars0 ratingsUltimate Hacking Challenge: Hacking the Planet, #3 Rating: 5 out of 5 stars5/5PowerShell: A Comprehensive Guide to Windows PowerShell Rating: 4 out of 5 stars4/5PowerShell Proficiency: An In-Depth Handbook for Automation and Scripting Rating: 0 out of 5 stars0 ratingsMastering Bash Scripting: From Basics to Expert Proficiency Rating: 0 out of 5 stars0 ratingsThe Complete Powershell Training for Beginners Rating: 0 out of 5 stars0 ratingsWindows Command Prompt Rating: 0 out of 5 stars0 ratingsWindows 10 Rating: 5 out of 5 stars5/5Getting Started with PowerShell Rating: 0 out of 5 stars0 ratings
Information Technology For You
Creating Online Courses with ChatGPT | A Step-by-Step Guide with Prompt Templates Rating: 4 out of 5 stars4/5Data Analytics for Beginners: Introduction to Data Analytics Rating: 4 out of 5 stars4/5Personal Knowledge Graphs: Connected thinking to boost productivity, creativity and discovery Rating: 5 out of 5 stars5/5CompTIA A+ CertMike: Prepare. Practice. Pass the Test! Get Certified!: Core 1 Exam 220-1101 Rating: 0 out of 5 stars0 ratingsA Mind at Play: How Claude Shannon Invented the Information Age Rating: 4 out of 5 stars4/5ChatGPT: The Future of Intelligent Conversation Rating: 4 out of 5 stars4/5An Ultimate Guide to Kali Linux for Beginners Rating: 3 out of 5 stars3/5Excel VBA: A Step-By-Step Tutorial For Beginners To Learn Excel VBA Programming From Scratch: 1 Rating: 4 out of 5 stars4/5AWS Certified Cloud Practitioner: Study Guide with Practice Questions and Labs Rating: 5 out of 5 stars5/5How to Write Effective Emails at Work Rating: 4 out of 5 stars4/520 Windows Tools Every SysAdmin Should Know Rating: 4 out of 5 stars4/5Cybersecurity for Beginners : Learn the Fundamentals of Cybersecurity in an Easy, Step-by-Step Guide: 1 Rating: 0 out of 5 stars0 ratingsIntroduction to Information Systems: Information Technology Essentials, #1 Rating: 0 out of 5 stars0 ratingsObject-Oriented JavaScript: Create scalable, reusable high-quality JavaScript applications, and libraries Rating: 3 out of 5 stars3/5CompTia Security 701: Fundamentals of Security Rating: 0 out of 5 stars0 ratingsMachine Learning Interview Questions Rating: 5 out of 5 stars5/5Cyber Security Consultants Playbook Rating: 0 out of 5 stars0 ratingsCOMPUTER SCIENCE FOR ROOKIES Rating: 0 out of 5 stars0 ratingsCybersecurity Playbook for Executives Rating: 0 out of 5 stars0 ratingsThe CISSP Fast-Track: Conquer the 8 Domains: CyberSecurity Rating: 0 out of 5 stars0 ratingsRisk Management and Information Systems Control Rating: 5 out of 5 stars5/5AWS Certified Cloud Practitioner - Practice Paper 3: AWS Certified Cloud Practitioner, #3 Rating: 5 out of 5 stars5/5CompTIA Network+ CertMike: Prepare. Practice. Pass the Test! Get Certified!: Exam N10-008 Rating: 0 out of 5 stars0 ratingsHealth Informatics: Practical Guide Rating: 0 out of 5 stars0 ratingsPractical Ethical Hacking from Scratch Rating: 5 out of 5 stars5/5The Rise of AI Income: Using Artificial Intelligence for Financial Success Rating: 5 out of 5 stars5/5CompTIA ITF+ CertMike: Prepare. Practice. Pass the Test! Get Certified!: Exam FC0-U61 Rating: 5 out of 5 stars5/5
Reviews for Mastering Windows Automation with AHK 2.0
0 ratings0 reviews
Book preview
Mastering Windows Automation with AHK 2.0 - John Nunez
Section 1: Introduction to AutoHotKey v 2.0......................................................14
History and Background....................................................................14
Evolution to AHK 2.0....................................................................14
Key Features of AHK 2.0.................................................................14
Applications and Uses...................................................................14
Getting Started with AHK 2.0..............................................................15
Hands on AHK v 2.0.0.....................................................................15
AHK Installation.......................................................................15
Step 1: Download AutoHotkey v 2.0.0.....................................................15
Step 2: Install AutoHotkey v 2.0.0........................................................16
Step 3: Configure AutoHotkey v 2.0.0.....................................................16
Additional Tips.....................................................................17
Using the AutoHotkey v 2.0 Program:........................................................17
Creating a Script....................................................................17
Editing a Script.....................................................................18
Running a Script....................................................................18
Tray Icon.........................................................................19
Main Window......................................................................20
Command Line Usage...................................................................20
Portability and Installation................................................................21
Section 2: Quick Start with AHK v 2.0...........................................................22
1. The Basics.........................................................................22
2. Hotkeys & Hotstrings..................................................................22
3. Sending Keystrokes..................................................................24
4. Running Programs & Websites..........................................................24
5. Function Calls with or without Parentheses..................................................25
6. Variables..........................................................................25
7. Objects............................................................................27
8. Other Helpful Goodies.................................................................27
Section 3: The AutoHotkey v 2.0.0 Dashboard.....................................................31
Using the AutoHotkey v 2.0.0 Dashboard.....................................................31
Step 1: Opening the AutoHotkey v 2.0.0 Dashboard..........................................31
Step 2: Exploring the Dashboard Interface.................................................31
Step 3: Creating and Running a Script....................................................32
Step 4: Using Window Spy.............................................................33
Step 5: Compiling a Script.............................................................33
Step 6: Accessing Help and Documentation................................................34
Section 4: The Window Spy Utility..............................................................35
Step-by-Step Instructions................................................................36
Example Usage in a Script...............................................................37
Explanation of the Script:.................................................................37
Section 5: General Conventions and Syntax......................................................38
General Conventions...................................................................38
Examples............................................................................38
Case Sensitivity and Naming...........................................................38
No Typed Variables..................................................................39
Optional Declarations................................................................39
Ignoring Spaces....................................................................39
Line Breaks and Continuation..........................................................39
Comments...........................................................................39
Examples............................................................................40
Single-line Comments................................................................40
Multi-line Comments.................................................................40
Expressions..........................................................................40
Examples............................................................................40
Simple Expressions..................................................................40
Complex Expressions................................................................41
Strings/Text.......................................................................41
Variables............................................................................41
Examples............................................................................41
Using Variables.....................................................................41
Concatenation......................................................................41
Operators............................................................................42
Examples............................................................................42
Unary and Binary Operators............................................................42
Precedence.......................................................................42
Function Calls.........................................................................42
Examples............................................................................43
Calling Functions....................................................................43
Function Call Statements..............................................................43
Control Flow Statements.................................................................43
Examples............................................................................43
If Statements.......................................................................43
Loops............................................................................44
Exception Handling..................................................................44
Challenge 1: Variable and Function Names...................................................44
Solution..........................................................................45
Challenge 2: No Typed Variables...........................................................45
Solution..........................................................................45
Challenge 3: Optional Declarations.........................................................45
Solution..........................................................................45
Challenge 4: Ignoring Spaces.............................................................45
Solution..........................................................................46
Challenge 5: Line Breaks and Continuation...................................................46
Solution..........................................................................46
Challenge 6: Comments.................................................................46
Solution..........................................................................46
Challenge 7: Expressions................................................................47
Solution..........................................................................47
Challenge 8: Using Variables..............................................................47
Solution..........................................................................47
Challenge 9: Operators..................................................................47
Solution..........................................................................47
Challenge 10: Function Calls..............................................................48
Solution..........................................................................48
Challenge 11: Control Flow Statements......................................................48
Solution..........................................................................48
Challenge 12: Exception Handling..........................................................48
Solution..........................................................................48
Section 6: Scripting Along with AHK V 2.0.......................................................50
Introduction..........................................................................50
Script Startup (The Auto-execute Thread).....................................................50
Splitting a Long Line into Shorter Ones......................................................51
Script Library Folders...................................................................51
Convert a Script to an EXE (Ahk2Exe).......................................................51
Passing Command Line Parameters to a Script................................................52
Script File Codepage....................................................................52
Debugging a Script.....................................................................53
Section 7: Variables & Arrays Explained.........................................................54
Clearing Variables.....................................................................54
Retrieving Variable Contents..............................................................54
Using Sub-Expressions..................................................................55
Boolean Values.......................................................................55
Empty Strings.........................................................................55
Literal Strings and Quotes................................................................56
Assigning Results of Expressions..........................................................56
Built-in Variables.......................................................................56
Logical and Comparison Operators.........................................................57
Arrays and Objects.....................................................................57
Handling Special Characters..............................................................57
More About Variables.......................................................................59
Storing Values in Variables...............................................................59
Clearing Variables.....................................................................59
Retrieving Variable Contents..............................................................59
Using Sub-Expressions..................................................................60
Boolean Values.......................................................................61
Empty Strings.........................................................................61
Literal Strings and Quotes................................................................61
Assigning Results of Expressions..........................................................62
Built-in Variables.......................................................................62
Logical and Comparison Operators.........................................................63
Arrays and Objects.....................................................................63
Handling Special Characters..............................................................64
But, what is an array?......................................................................64
Creating an Array......................................................................64
Accessing Array Elements................................................................64
Modifying Array Elements................................................................65
Adding Elements to an Array..............................................................65
Removing Elements from an Array..........................................................65
Looping Through an Array................................................................66
Associative Arrays (Objects)..............................................................66
Accessing Object Properties..............................................................66
Modifying Object Properties...............................................................67
Adding Properties to an Object............................................................67
Removing Properties from an Object........................................................67
Looping Through Object Properties.........................................................68
Multi-Dimensional Arrays.................................................................68
Combining Arrays and Objects............................................................68
Practical Example: Managing a To-Do List....................................................69
Section 8: Hotkeys - Modifier Symbols..........................................................71
Definition & Usage........................................................................71
Dynamic Hotkeys and Named Function Hotkeys..................................................71
Dynamic Hotkeys......................................................................71
Detailed Examples of Dynamic Hotkeys:...................................................72
1. Creating Dynamic Hotkeys:..........................................................72
2. Modifying Dynamic Hotkeys:.........................................................73
3. Removing Dynamic Hotkeys:.........................................................73
Named Function Hotkeys................................................................74
1. Creating Named Function Hotkeys:.....................................................74
2. Combining Multiple Named Function Hotkeys:.............................................74
Practical Use Cases....................................................................75
Summary of Benefits.................................................................75
More Examples of Dynamic Hotkeys........................................................76
1. Context-Sensitive Hotkeys:...........................................................76
2. Creating and Deleting Hotkeys on the Fly:................................................78
More Examples of Named Function Hotkeys................................................79
1. Direct Function Assignments:.........................................................79
2. Multiple Hotkeys for the Same Function:.................................................80
Advanced Use Cases...................................................................80
1. User-Configurable Hotkeys:..........................................................80
2. Mode-Specific Hotkeys:.............................................................81
Practice Section - Hotkeys - Modifier Symbols Definition & Usage...................................84
Hotkey Modifier Symbols.................................................................84
Section 9: Sending Keystrokes................................................................90
Key Points...........................................................................90
Basics of Sending Keystrokes:..........................................................90
Rules of Quoted Strings:..............................................................90
Sending Key Combinations:............................................................91
Hotkeys vs. Send:...................................................................91
Blind Mode:........................................................................91
Modes and Options:.................................................................92
Timing and Delays:..................................................................92
Sending Large Amounts of Text:........................................................92
Advanced Usage Tips...................................................................93
ControlSend for Background Applications:.................................................93
Adjusting Send Modes:...............................................................93
Error Handling:.....................................................................94
Script Efficiency:....................................................................94
Section 10: Scripts: Multiple Scripts in a Single File................................................95
Here's the analysis of the above AHK v 2.0.0 scripts:............................................96
Script Overview.......................................................................96
Detailed Breakdown.................................................................96
Example: Accessing Google.com Search........................................................98
Explanation:..........................................................................98
Section 11: Managing Windows...............................................................100
Key Points..........................................................................100
Examples...........................................................................101
Basic Window Management:
AHK Code
; Open a new Notepad window and move it................................................101
Using Window Class:
AHK Code
; Open Notepad and manipulate using its class.............................................101
Using Process Name:
AHK Code
; Open Notepad and manipulate using the process name......................................101
Using Process ID:
AHK Code
; Open Notepad and manipulate using its process ID.........................................102
Handling Timeouts:
AHK Code
; Open Notepad with a timeout for waiting.................................................102
Using Last Found Window:
AHK Code
; Manipulate the last found window......................................................102
Moving Active Window with Hotkeys:
AHK Code
; Move the active window by 10 pixels with arrow keys........................................103
Deep We Go!...........................................................................103
Key Points..........................................................................103
Advanced Window Manipulation:.......................................................103
Advanced Identification:..............................................................104
Handling Multiple Windows:...........................................................104
Interacting with Controls:.............................................................104
Window Styles and Extended Styles:....................................................104
Examples...........................................................................104
Example 1: Setting a Window to Always Be on Top.............................................104
Example 2: Changing Window Title........................................................104
Example 3: Setting Transparent Color......................................................105
Example 4: Using Multiple Criteria for Identification.............................................105
Example 5: Handling Multiple Windows.....................................................105
Example 6: Interacting with Controls.......................................................105
Example 7: Retrieving Text from a Control...................................................106
Example 8: Changing Window Styles.......................................................106
Example 9: Changing Window Extended Styles...............................................106
Advanced Usage Tips.....................................................................106
Section 12: Alphabetical Function Index........................................................108
Key Points.............................................................................108
Math Functions:......................................................................108
String Functions:......................................................................108
File Functions:.......................................................................108
GUI and Window Management:...........................................................109
Clipboard Functions:...................................................................109
Examples...........................................................................109
Using Math Functions:
AHK Code
num := -5........................................................................109
String Manipulation:
AHK Code
str := hello world
..................................................................109
File Operations:
AHK Code
FileAppend(Hello, World!
, example.txt
)...................................................110
Creating a Simple GUI:
AHK Code
gui := GuiCreate().....................................................................110
Window Management:
AHK Code
WinActivate(Untitled - Notepad
).......................................................110
Clipboard Handling:
AHK Code
clipboard := Hello, Clipboard!
.........................................................110
Section 13: Basic and Advanced Object Oriented Programming......................................111
Understanding Object-Oriented Programming (OOP)..............................................111
Key Concepts of OOP:.................................................................111
OOP in AutoHotkey v 2.0.0..............................................................111
Creating a Class...................................................................111
Creating an Object..................................................................112
Inheritance.......................................................................112
Encapsulation.....................................................................113
Polymorphism.....................................................................113
Practical Example: Simple Bank Account Management.............................................114
Advanced Object-Oriented Programming Concepts in AutoHotkey v 2.0..............................116
Properties and Methods..............................................................116
Class Methods vs. Instance Methods....................................................117
Inheritance and Method Overriding......................................................117
Encapsulation with Private Methods and Properties..........................................118
Using Constructors and Destructors.....................................................119
Polymorphism with Interfaces..........................................................121
Section 14: GUI Objects.....................................................................123
Creating and Managing GUI Windows:........................................................123
Common Methods:.......................................................................123
Properties:.............................................................................123
Examples..............................................................................124
Creating a Simple GUI:
AHK Code
MyGui := Gui(, Simple Input Example
).....................................................124
Using Different Controls and Methods:
AHK Code
MyGui := Gui(, Example GUI
)...........................................................124
Setting Window Options:
AHK Code
MyGui := Gui(, Window with Options
)......................................................125
Handling Window Events:
AHK Code
MyGui := Gui().......................................................................125
Modifying Window Appearance:
AHK Code
MyGui := Gui(, Customized Window
)......................................................125
Additional Remarks....................................................................126
Article 15: AHK Keys for the Keyboard, Mouse, and Controller.......................................127
Mouse.............................................................................127
Keyboard...........................................................................127
Game Controller (Gamepad, Joystick, etc.).....................................................129
Special Keys and Custom Keys..............................................................129
Example Usage......................................................................129
Explanation:.........................................................................131
Section 16: Compiling an AHK Script..........................................................133
The AHK V 2.0 Compiler Ahk2EXE for AutoHotkey.............................................133
Download and Install AutoHotkey v 2.0.0:....................................................133
Prepare Your Script:...................................................................133
Locate the Compiler:...................................................................134
Open Ahk2Exe:......................................................................134
Compile Your Script:...................................................................134
Verify the Executable:..................................................................134
Section 17: AHK v 2.0 Weekly Bootcamp........................................................135
Day 1: Getting Started..................................................................135
Day 2: Hotkeys and Hotstrings............................................................135
Day 3: Sending Keystrokes..............................................................136
Day 4: Running Programs and Websites....................................................137
Day 5: