AutoHotkey Integration Reference¶
Complete reference for skippy-ahk.ahk - Desktop automation via AutoHotkey v2.
Requirements¶
- AutoHotkey v2 installed
- Default location:
C:\Program Files\AutoHotkey\v2\AutoHotkey64.exe
Basic Usage¶
$ahk = "C:\Program Files\AutoHotkey\v2\AutoHotkey64.exe"
& $ahk "C:\Users\ejb71\SkippyBuddy\tools\skippy-ahk.ahk" <command> [args...]
Commands¶
click¶
Click at screen coordinates.
Parameters:
| Parameter | Type | Required | Default | Values |
|---|---|---|---|---|
| x | Integer | Yes | - | X coordinate |
| y | Integer | Yes | - | Y coordinate |
| button | String | No | left | left, right, middle |
Examples:
# Left click at (100, 200)
& $ahk tools\skippy-ahk.ahk click 100 200
# Right click
& $ahk tools\skippy-ahk.ahk click 500 300 right
# Middle click
& $ahk tools\skippy-ahk.ahk click 500 300 middle
Output: OK: Clicked left at 100,200
dclick¶
Double-click at screen coordinates.
Examples:
Output: OK: Double-clicked at 150,300
move¶
Move mouse cursor to coordinates.
Examples:
# Move to top-left corner
& $ahk tools\skippy-ahk.ahk move 0 0
# Move to specific position
& $ahk tools\skippy-ahk.ahk move 500 300
Output: OK: Moved to 500,300
type¶
Type a text string (simulates keyboard input).
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| text | String | Yes | Text to type (can include special keys) |
Special Keys in Type:
| Key | Syntax |
|---|---|
| Enter | {Enter} |
| Tab | {Tab} |
| Backspace | {Backspace} or {BS} |
| Delete | {Delete} or {Del} |
| Escape | {Escape} or {Esc} |
| Space | {Space} |
| Arrow keys | {Up}, {Down}, {Left}, {Right} |
Examples:
# Simple text
& $ahk tools\skippy-ahk.ahk type "Hello World"
# Multi-line
& $ahk tools\skippy-ahk.ahk type "Line 1{Enter}Line 2{Enter}Line 3"
# With tabs
& $ahk tools\skippy-ahk.ahk type "Name{Tab}Value{Tab}Description"
Output: OK: Typed 11 characters
send¶
Send keystrokes using AHK syntax.
Key Modifiers:
| Symbol | Modifier |
|---|---|
^ |
Ctrl |
! |
Alt |
+ |
Shift |
# |
Windows |
Common Key Sequences:
| Keys | Meaning |
|---|---|
^c |
Ctrl+C (copy) |
^v |
Ctrl+V (paste) |
^s |
Ctrl+S (save) |
^z |
Ctrl+Z (undo) |
^a |
Ctrl+A (select all) |
!{F4} |
Alt+F4 (close window) |
^+s |
Ctrl+Shift+S (save as) |
#{r} |
Win+R (run dialog) |
#{d} |
Win+D (show desktop) |
#{e} |
Win+E (explorer) |
{Enter} |
Enter key |
{Escape} |
Escape key |
{F1} - {F12} |
Function keys |
Examples:
# Copy selection
& $ahk tools\skippy-ahk.ahk send "^c"
# Paste
& $ahk tools\skippy-ahk.ahk send "^v"
# Save document
& $ahk tools\skippy-ahk.ahk send "^s"
# Close window
& $ahk tools\skippy-ahk.ahk send "!{F4}"
# Open Run dialog
& $ahk tools\skippy-ahk.ahk send "#{r}"
# Press Enter
& $ahk tools\skippy-ahk.ahk send "{Enter}"
# Ctrl+Shift+S
& $ahk tools\skippy-ahk.ahk send "^+s"
Output: OK: Sent keys
getpos¶
Get current mouse cursor position.
Output: POS:500,300
Usage in PowerShell:
$pos = & $ahk tools\skippy-ahk.ahk getpos
if ($pos -match "POS:(\d+),(\d+)") {
$x = $matches[1]
$y = $matches[2]
Write-Host "Mouse at X=$x, Y=$y"
}
activate¶
Bring a window to the foreground by title.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| title | String | Yes | Window title (partial match) |
Examples:
# Activate Notepad
& $ahk tools\skippy-ahk.ahk activate "Notepad"
# Activate by partial title
& $ahk tools\skippy-ahk.ahk activate "Visual Studio Code"
# Activate specific file
& $ahk tools\skippy-ahk.ahk activate "readme.md"
Output:
- Success: OK: Activated window
- Failure: ERROR: Window not found: Notepad
wait¶
Wait for a window to appear, then activate it.
Parameters:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| title | String | Yes | - | Window title to wait for |
| timeout | Integer | No | 10 | Seconds to wait |
Examples:
# Wait up to 10 seconds for Save dialog
& $ahk tools\skippy-ahk.ahk wait "Save As"
# Wait up to 30 seconds
& $ahk tools\skippy-ahk.ahk wait "Download Complete" 30
Output:
- Success: OK: Window appeared
- Timeout: ERROR: Window did not appear within 10s
help¶
Show help message with all commands.
Complete Example Workflows¶
Open Notepad and Write Text¶
$ahk = "C:\Program Files\AutoHotkey\v2\AutoHotkey64.exe"
# Open Notepad via Run dialog
& $ahk tools\skippy-ahk.ahk send "#{r}"
Start-Sleep -Milliseconds 500
& $ahk tools\skippy-ahk.ahk type "notepad"
& $ahk tools\skippy-ahk.ahk send "{Enter}"
# Wait for window
& $ahk tools\skippy-ahk.ahk wait "Untitled - Notepad" 5
# Type content
& $ahk tools\skippy-ahk.ahk type "Hello from Skippy!{Enter}{Enter}This was automated."
# Save
& $ahk tools\skippy-ahk.ahk send "^s"
Copy Text from One App to Another¶
# Activate source window
& $ahk tools\skippy-ahk.ahk activate "Source Document"
Start-Sleep -Milliseconds 200
# Select all and copy
& $ahk tools\skippy-ahk.ahk send "^a"
& $ahk tools\skippy-ahk.ahk send "^c"
Start-Sleep -Milliseconds 100
# Activate destination
& $ahk tools\skippy-ahk.ahk activate "Destination"
Start-Sleep -Milliseconds 200
# Paste
& $ahk tools\skippy-ahk.ahk send "^v"
Fill a Form¶
# Activate form window
& $ahk tools\skippy-ahk.ahk activate "Registration Form"
# Fill fields (Tab between them)
& $ahk tools\skippy-ahk.ahk type "John Doe{Tab}"
& $ahk tools\skippy-ahk.ahk type "john@example.com{Tab}"
& $ahk tools\skippy-ahk.ahk type "555-1234{Tab}"
# Submit (assuming button is focused)
& $ahk tools\skippy-ahk.ahk send "{Enter}"
Error Handling¶
All commands return output text starting with:
OK:- SuccessERROR:- FailurePOS:- Position data (getpos only)
PowerShell Pattern:
$result = & $ahk tools\skippy-ahk.ahk activate "Window"
if ($result -match "^ERROR:") {
Write-Host "Failed: $result"
} else {
Write-Host "Success"
}
Troubleshooting¶
"AutoHotkey not found"¶
Verify installation:
"Window not found"¶
- Check exact window title (case-sensitive)
- Try partial title match
- Ensure window exists:
Commands not working¶
- Run AHK script directly to see errors
- Check if target app blocks automation
- Verify coordinates are on-screen
Security Notes¶
Automation Risks
AHK can: - Send any keystrokes (including passwords if typed) - Click anywhere on screen - Interact with any application
Use with caution and never automate sensitive operations.
Focus Requirements
Most commands require the target window to be focused. Use activate first.