AutoHotkey: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
|||
| (12 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
== AutoHotkey == | == AutoHotkey == | ||
AutoHotkey | |||
https://www.autohotkey.com/ | |||
== Tutorial == | |||
Quick Reference | AutoHotkey v2 | |||
https://www.autohotkey.com/docs/v2/index.htm | |||
== Version 2 Header == | |||
<pre> | |||
#Requires AutoHotkey v2.0 | |||
... | |||
</pre> | |||
== Variables == | |||
Assignment: | |||
MyNumber = 123 | |||
MyString = This is a literal string. | |||
CopyOfVar = %Var% ; With the = operator, percent signs are required to retrieve a variable's contents. | |||
Expressions: | |||
MyNumber := 123 | |||
MyString := "This is a literal string." | |||
CopyOfVar := Var ; Unlike its counterpart in the previous section, percent signs are not used with the := operator. | |||
Erase: | |||
MyVar = | |||
MyVar := "" | |||
ref: https://www.autohotkey.com/docs/v1/Variables.htm | |||
== For Loop == | |||
<pre> | |||
colours := Object("red", 0xFF0000, "blue", 0x0000FF, "green", 0x00FF00) | |||
; The above expression could be used directly in place of "colours" below: | |||
for k, v in colours | |||
s .= k "=" v "`n" | |||
MsgBox % s | |||
</pre> | |||
ref: https://www.autohotkey.com/docs/v1/lib/For.htm | |||
== While Loop == | |||
<pre> | |||
while some_condition | |||
{ | |||
... | |||
} | |||
</pre> | |||
ref: https://www.autohotkey.com/docs/v1/lib/While.htm | |||
== Functions == | |||
<pre> | |||
Add(x, y) | |||
{ | |||
return x + y ; "Return" expects an expression. | |||
} | |||
</pre> | |||
ref: https://www.autohotkey.com/docs/v1/Functions.htm | |||
== Let's Game It Out reference == | == Let's Game It Out reference == | ||
| Line 9: | Line 78: | ||
f12:: | f12:: | ||
Start | Start: | ||
MouseClick | MouseClick | ||
| Line 18: | Line 87: | ||
The "sleep, 1" is 1 millisecond = 1,000 timess/second | The "sleep, 1" is 1 millisecond = 1,000 timess/second | ||
<pre> | |||
^f12:: | |||
Start: | |||
MouseClick | |||
sleep, 1 | |||
KeyIsDown := GetKeyState("F12") | |||
if KeyIsDown | |||
return | |||
Goto, Start | |||
; ^f12:: | |||
; Run, notepad.exe | |||
; return | |||
</pre> | |||
== auto mouse press with escape key exit == | |||
<pre> | |||
^J:: | |||
LOOP { | |||
MOUSECLICK, LEFT | |||
SLEEP, 100 | |||
} | |||
Esc::ExitApp | |||
</pre> | |||
== Send message == | |||
Send key presses: https://www.autohotkey.com/docs/v1/lib/Send.htm | https://www.autohotkey.com/docs/v2/lib/Send.htm | |||
On Ctrl+F12: | |||
<pre> | |||
^f12:: | |||
Send {h}{e}{l}{l}{o} | |||
</pre> | |||
SendInput is faster then send: https://www.autohotkey.com/docs/v2/lib/Send.htm | |||
<pre> | |||
^k:: ; Press Ctrl+K | |||
SendInput This is a very long string of text... | |||
return | |||
</pre> | |||
<pre> | |||
SendInput {raw}This has ! special characters! | |||
</pre> | |||
== Clipboard Manipulation == | |||
<pre> | |||
^j:: ; Press Ctrl+J to trigger | |||
clipboard := "Your large block of text goes here." | |||
ClipWait ; Wait for the clipboard to contain data | |||
Send ^v ; Paste the text | |||
return | |||
</pre> | |||
== Arrow Keys == | |||
<pre> | |||
r:: | |||
Send {Right down} | |||
Sleep 500 | |||
Send {Right up} | |||
return | |||
</pre> | |||
<pre> | |||
Send {Down down} ; Presses the down arrow key down | |||
Sleep 1000 ; Keeps it held down for 1 second | |||
Send {Down up} ; Releases the down arrow key | |||
return | |||
</pre> | |||
== keywords == | == keywords == | ||
Latest revision as of 06:51, 30 May 2026
AutoHotkey
AutoHotkey https://www.autohotkey.com/
Tutorial
Quick Reference | AutoHotkey v2 https://www.autohotkey.com/docs/v2/index.htm
Version 2 Header
#Requires AutoHotkey v2.0 ...
Variables
Assignment:
MyNumber = 123 MyString = This is a literal string. CopyOfVar = %Var% ; With the = operator, percent signs are required to retrieve a variable's contents.
Expressions:
MyNumber := 123 MyString := "This is a literal string." CopyOfVar := Var ; Unlike its counterpart in the previous section, percent signs are not used with the := operator.
Erase:
MyVar = MyVar := ""
ref: https://www.autohotkey.com/docs/v1/Variables.htm
For Loop
colours := Object("red", 0xFF0000, "blue", 0x0000FF, "green", 0x00FF00)
; The above expression could be used directly in place of "colours" below:
for k, v in colours
s .= k "=" v "`n"
MsgBox % s
ref: https://www.autohotkey.com/docs/v1/lib/For.htm
While Loop
while some_condition
{
...
}
ref: https://www.autohotkey.com/docs/v1/lib/While.htm
Functions
Add(x, y)
{
return x + y ; "Return" expects an expression.
}
ref: https://www.autohotkey.com/docs/v1/Functions.htm
Let's Game It Out reference
I Broke This Game So Hard, Its Whole Universe Gave Up - Outpath https://www.youtube.com/watch?v=0FKaIiRhUME
HitMeWithThatClickyClickScriptyScript.ahk :
f12:: Start: MouseClick sleep, 1 Goto, Start
The "sleep, 1" is 1 millisecond = 1,000 timess/second
^f12::
Start:
MouseClick
sleep, 1
KeyIsDown := GetKeyState("F12")
if KeyIsDown
return
Goto, Start
; ^f12::
; Run, notepad.exe
; return
auto mouse press with escape key exit
^J::
LOOP {
MOUSECLICK, LEFT
SLEEP, 100
}
Esc::ExitApp
Send message
Send key presses: https://www.autohotkey.com/docs/v1/lib/Send.htm | https://www.autohotkey.com/docs/v2/lib/Send.htm
On Ctrl+F12:
^f12::
Send {h}{e}{l}{l}{o}
SendInput is faster then send: https://www.autohotkey.com/docs/v2/lib/Send.htm
^k:: ; Press Ctrl+K SendInput This is a very long string of text... return
SendInput {raw}This has ! special characters!
Clipboard Manipulation
^j:: ; Press Ctrl+J to trigger clipboard := "Your large block of text goes here." ClipWait ; Wait for the clipboard to contain data Send ^v ; Paste the text return
Arrow Keys
r::
Send {Right down}
Sleep 500
Send {Right up}
return
Send {Down down} ; Presses the down arrow key down
Sleep 1000 ; Keeps it held down for 1 second
Send {Down up} ; Releases the down arrow key
return