User Tools

Site Tools


autohotkey_recipes

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
autohotkey_recipes [2015/07/11 14:15] tkbletscautohotkey_recipes [2026/03/19 15:23] (current) tkbletsc
Line 1: Line 1:
-[[http://www.autohotkey.com/|AutoHotKey]] does input macro programming and keyboard remapping in Windows.  Key docs:+[[http://www.autohotkey.com/|AutoHotKey]] does input macro programming and keyboard remapping in Windows. Key docs:
  
   * [[http://www.autohotkey.com/docs/misc/Remap.htm|Remapping keys and buttons]]   * [[http://www.autohotkey.com/docs/misc/Remap.htm|Remapping keys and buttons]]
Line 7: Line 7:
  
 ====== Recipes ====== ====== Recipes ======
-Below are some useful recipes.  See also:  
-  * [[Using AutoHotKey to map keys on the Amtelco KB163 Unified Keyboard]]. 
-  * [[Using AutoHotkey to make a second mouse into a multimedia control]] 
  
-===== General =====+Below are some useful recipes. See also:
  
 +  * [[:using_autohotkey_to_map_keys_on_the_amtelco_kb163_unified_keyboard|Using AutoHotKey to map keys on the Amtelco KB163 Unified Keyboard]].
 +  * [[:using_autohotkey_to_make_a_second_mouse_into_a_multimedia_control|Using AutoHotkey to make a second mouse into a multimedia control]]
 +
 +===== General =====
 <file> <file>
 +
 ; General controls: ; General controls:
 ;   Win+Esc       to reload ;   Win+Esc       to reload
Line 22: Line 24:
 #^Escape::Edit #^Escape::Edit
  
-; Win+Backtick = Sleep +; Win+F12 = Sleep 
-#`::DllCall("PowrProf\SetSuspendState", "int", 0, "int", 0, "int", 0)+#F12::DllCall("PowrProf\SetSuspendState", "int", 0, "int", 0, "int", 0)
  
 ; Win+M = toggle mute ; Win+M = toggle mute
 #m::Send {Volume_Mute} #m::Send {Volume_Mute}
 +
 +; Alt+Backtick -> Shift+Win_Right (move window to next monitor) -- a shortcut I used on Ultramon for years
 +!`::Send +#{Right}
 +
 +</file>
 +
 +===== Capslock on a timer =====
 +<file>
 +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 +; --- CapsLock hold-to-enable, tap-to-disable ---
 +
 +CapsLock::
 +    capsHoldTime := 500   ; ms required to enable
 +
 +    ; If already ON → turn OFF immediately
 +    if GetKeyState("CapsLock", "T") {
 +        SetCapsLockState, Off
 +        SoundBeep, 800, 50  ; disable chirp
 +        SoundBeep, 600, 50
 +        return
 +    }
 +
 +    ; Start hold detection
 +    SoundBeep, 600, 40   ; start-of-hold chirp
 +    start := A_TickCount
 +
 +    while GetKeyState("CapsLock", "P") {
 +        if (A_TickCount - start >= capsHoldTime) {
 +            SetCapsLockState, On
 +            SoundBeep, 600, 50   ; enable chirp
 +            SoundBeep, 800, 50
 +
 +            ; --- critical fix ---
 +            KeyWait, CapsLock   ; wait until key is released
 +
 +            return
 +        }
 +        Sleep, 10
 +    }
 +
 +    ; Released early → do nothing
 +return
 </file> </file>
  
 ===== Hold down any key ===== ===== Hold down any key =====
 +
 <file> <file>
-; do right win key + whatever to hold that key down (if it's listed below) +; do right win key + whatever to hold that key down (if it's listed below)>#w::Send {w down}
->#w::Send {w down}+
 >#a::Send {a down} >#a::Send {a down}
 >#s::Send {s down} >#s::Send {s down}
Line 41: Line 85:
 >#q::Send {q down} >#q::Send {q down}
 >#e::Send {e down} >#e::Send {e down}
 +
 </file> </file>
  
 ===== Map gamepad buttons to winamp controls ===== ===== Map gamepad buttons to winamp controls =====
 +
 All the function gunk around Joy2 and Joy3 is for keyboard auto-repeat of Win+A and Win+S (which I map to winamp volume control elsewhere). All the function gunk around Joy2 and Joy3 is for keyboard auto-repeat of Win+A and Win+S (which I map to winamp volume control elsewhere).
 +
 <file> <file>
 ; winamp control (if winamp is running) ; winamp control (if winamp is running)
-#If WinExist("ahk_class BaseWindow_RootWnd") ; << this badly named thing refers to winamp+#If WinExist("ahk_class BaseWindow_RootWnd") ; <<this badly named thing refers to winamp
 Joy1::Send {Media_Play_Pause} Joy1::Send {Media_Play_Pause}
 Joy4::Send {Media_Stop} Joy4::Send {Media_Stop}
Line 85: Line 132:
   return   return
 #If ; EndIf #If ; EndIf
 +
 </file> </file>
  
 ===== Make the top edge of the main monitor "sticky" ===== ===== 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.+ 
 +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. 
 <file> <file>
 SetupClipCheck() ; enable the mouse confinement system (defined below) SetupClipCheck() ; enable the mouse confinement system (defined below)
  
 ; get access to the winapi ClipCursor function, which limits cursor boundaries ; get access to the winapi ClipCursor function, which limits cursor boundaries
-ClipCursor( Confine=True, x1=0 , y1=0, x2=1, y2=1 ) +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)  VarSetCapacity(R,16,0),  NumPut(x1,&R+0),NumPut(y1,&R+4),NumPut(x2,&R+8),NumPut(y2,&R+12)
Line 105: Line 155:
 } }
  
-top_tick_count := 0   +top_tick_count := 0
 ClipCheck: ClipCheck:
  CoordMode, Mouse, Screen  CoordMode, Mouse, Screen
Line 111: Line 161:
  ;ToolTip,%x%:%y%:%top_tick_count%  ;ToolTip,%x%:%y%:%top_tick_count%
  
- If (y < 10) {+ If (y <10) {
    top_tick_count++    top_tick_count++
  } Else {  } Else {
Line 123: Line 173:
  }  }
  return  return
 +
 </file> </file>
  
 ===== Extended mouse buttons mapped to media control ===== ===== Extended mouse buttons mapped to media control =====
 +
 <file> <file>
 XButton2::Media_Play_Pause XButton2::Media_Play_Pause
 XButton1::Media_Next XButton1::Media_Next
 +
 </file> </file>
  
 ===== Mouse click spam ===== ===== Mouse click spam =====
 +
 Press F7 to toggle auto-clicking over and over as fast as possible. Press F7 to toggle auto-clicking over and over as fast as possible.
 +
 <file> <file>
-i:=0 +i:=0
 F7::SetTimer, Spam, % (i:=!i) ? "10" : "Off" ; uses ternary F7::SetTimer, Spam, % (i:=!i) ? "10" : "Off" ; uses ternary
  
-Spam: +Spam:
    Click    Click
    Send {LButton}    Send {LButton}
 return return
 +
 </file> </file>
  
 ===== Winkey shortcut overrides ===== ===== 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.+ 
 +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 media keys or other key combos that apps can hook without issue. 
 <file> <file>
 ; WinAmp+Launchy remaps ; WinAmp+Launchy remaps
-#x::#^+#z::Media_Prev 
-#b::#^+#x::Media_Play_Pause 
-#space::^#Space+#c::Media_Play_Pause 
 +#v::Media_Stop 
 +#b::Media_Next 
 +#space::Send ^+{Space
 +; ^ Win+Space -> Ctrl+Shift+Space 
 + 
 +; old simple winamp remaps -- the newer ones above let it work for non-winamps, such as spotify 
 +;#x::#^x 
 +;#b::#^b 
 </file> </file>
 +
 ===== Auto mouse ===== ===== Auto mouse =====
 +
 <file> <file>
-; Auto mouse click: +; Auto mouse click:
 ;  Win+Shift+I      to auto click slowly ;  Win+Shift+I      to auto click slowly
 ;  Win+Shift+Ctrl+I to auto click quickly ;  Win+Shift+Ctrl+I to auto click quickly
Line 181: Line 250:
  
 ===== FoxIt ===== ===== FoxIt =====
 +
 The F5 for reload only works if the active file is the most recently opened. The F5 for reload only works if the active file is the most recently opened.
  
Line 188: Line 258:
 F5::Send ^w!fr1 F5::Send ^w!fr1
 #IfWinActive #IfWinActive
 +
 </file> </file>
  
 ===== Terraria ===== ===== Terraria =====
 +
 <file> <file>
 ; Terraria: middle click is turbo left click ; Terraria: middle click is turbo left click
 #IfWinActive, ahk_class WindowsForms10.Window.8.app.0.ea7f4a_r16_ad1 #IfWinActive, ahk_class WindowsForms10.Window.8.app.0.ea7f4a_r16_ad1
 MButton:: MButton::
- SetTimer DoClick,50 +    SetTimer DoClick,50 
- SoundBeep 880,50 +    SoundBeep 880,50 
- return+    return
 MButton up:: MButton up::
- SetTimer DoClick,off +    SetTimer DoClick,off 
- SoundBeep 440,50 +    SoundBeep 440,50 
- return+    return
 #IfWinActive #IfWinActive
 +
 </file> </file>
- 
  
 ===== Suppress F1 in Explorer, Word, and Excel ===== ===== 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.+ 
 +The code below will replace the annoying help popup with a low-pitched beep. Change "SoundBeep" to "Return" for silent operation. 
 <file> <file>
 ; Suppress F1 in Explorer/Word/Excel -- replace the annoying help popup with a low-pitched beep ; Suppress F1 in Explorer/Word/Excel -- replace the annoying help popup with a low-pitched beep
Line 217: Line 291:
 F1::SoundBeep 110,100 F1::SoundBeep 110,100
 #IfWinActive #IfWinActive
 +
 </file> </file>
 +
 ===== Minecraft movement ===== ===== Minecraft movement =====
  
Line 243: Line 319:
  return  return
  
-MButton:: +MButton::
  SetKeyDelay 55  SetKeyDelay 55
  Send {w down}{w up}{w down}  Send {w down}{w up}{w down}
Line 250: Line 326:
  return  return
  
-^MButton:: +^MButton::
  SetKeyDelay 55  SetKeyDelay 55
  Send {w down}{w up}{w down}  Send {w down}{w up}{w down}
Line 256: Line 332:
  return  return
 #IfWinActive #IfWinActive
-</file> 
  
 +</file>
  
  
autohotkey_recipes.1436649330.txt.gz · Last modified: by tkbletsc

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki