This is an old revision of the document!
Table of Contents
AutoHotKey does input macro programming and keyboard remapping in Windows. Key docs:
Recipes
Below are some useful recipes. See also:
General
; General controls: ; Win+Esc to reload ; Win+Shift+Esc to exit ; Win+Ctrl+Esc to exit #Escape::Reload #+Escape::ExitApp #^Escape::Edit ; Win+Backtick = Sleep #`::DllCall("PowrProf\SetSuspendState", "int", 0, "int", 0, "int", 0) ; Win+M = toggle mute #m::Send {Volume_Mute}
Make the top edge of the main monitor "sticky"
If you have a second monitor above the main one, this script will help you still be able to click stuff at the top of the screen without accidentally wandering into the upper monitor.
SetupClipCheck() ; enable the mouse confinement system (defined below) ; get access to the winapi ClipCursor function, which limits cursor boundaries ClipCursor( Confine=True, x1=0 , y1=0, x2=1, y2=1 ) { VarSetCapacity(R,16,0), NumPut(x1,&R+0),NumPut(y1,&R+4),NumPut(x2,&R+8),NumPut(y2,&R+12) Return Confine ? DllCall( "ClipCursor", UInt,&R ) : DllCall( "ClipCursor" ) } ; count the number of loop iterations the mouse has been near the top and un-confine the mouse if there's been enough SetupClipCheck() { SetTimer, ClipCheck, 10 return } top_tick_count := 0 ClipCheck: CoordMode, Mouse, Screen MouseGetPos,x,y ;ToolTip,%x%:%y%:%top_tick_count% If (y < 10) { top_tick_count++ } Else { top_tick_count := 0 } if (top_tick_count>15) { ClipCursor(False) } Else { ClipCursor(True, -10000, 0, 10000, 10000) } return
Extended mouse buttons mapped to media control
XButton2::Media_Play_Pause XButton1::Media_Next
Mouse click spam
Press F7 to toggle auto-clicking over and over as fast as possible.
i:=0 F7::SetTimer, Spam, % (i:=!i) ? "10" : "Off" ; uses ternary Spam: Click Send {LButton} return
Winkey shortcut overrides
Windows by default binds Win+X, Win+B, and Win+Space to stuff I don't care about. The script below will remap these to Win+Ctrl+<key>, which you can bind to apps without issue.
; WinAmp+Launchy remaps #x::#^x #b::#^b #space::^#Space
Auto mouse
; Auto mouse click: ; Win+Shift+I to auto click slowly ; Win+Shift+Ctrl+I to auto click quickly ; Win+I to auto stop #+i:: SetTimer DoClick,500 SoundBeep 440,100 SoundBeep 660,100 return #+^i:: SetTimer DoClick,50 SoundBeep 440,100 SoundBeep 660,100 SoundBeep 880,100 return #i:: SetTimer DoClick,off SoundBeep 660,100 SoundBeep 440,100 return DoClick: Send {LButton} SoundBeep 200,10 return
FoxIt
The F5 for reload only works if the active file is the most recently opened.
; FoxIt keys: F5=reload #IfWinActive, ahk_class classFoxitReader F5::Send ^w!fr1 #IfWinActive
Terraria
; Terraria: middle click is turbo left click #IfWinActive, ahk_class WindowsForms10.Window.8.app.0.ea7f4a_r16_ad1 MButton:: SetTimer DoClick,50 SoundBeep 880,50 return MButton up:: SetTimer DoClick,off SoundBeep 440,50 return #IfWinActive
Suppress F1 in Explorer, Word, and Excel
The code below will replace the annoying help popup with a low-pitched beep. Change "SoundBeep…" to "Return" for silent operation.
; Suppress F1 in Explorer/Word/Excel -- replace the annoying help popup with a low-pitched beep #IfWinActive ahk_class CabinetWClass F1::SoundBeep 110,100 #IfWinActive ahk_class OpusApp F1::SoundBeep 110,100 #IfWinActive ahk_class XLMAIN F1::SoundBeep 110,100 #IfWinActive
Minecraft movement
; Ctrl+W = hold W (auto-run) ; Ctrl+LButton = hold LButton (auto-mine) ; Ctrl+RButton = hold RButton (auto-use) ; MButton = Sprint without double-tapping W ; Ctrl+MButton = hold MButton (auto-sprint) #IfWinActive Minecraft ahk_class SunAwtFrame ^w:: Send {w down} SoundBeep 500,100 return ^LButton:: Send {LButton down} SoundBeep 500,100 return ^RButton:: Send {RButton down} SoundBeep 500,100 return MButton:: SetKeyDelay 55 Send {w down}{w up}{w down} KeyWait MButton Send {w up} return ^MButton:: SetKeyDelay 55 Send {w down}{w up}{w down} SoundBeep 500,100 return #IfWinActive