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 revision Previous revision
Next revision
Previous revision
autohotkey_recipes [2012/05/20 10:38]
tkbletsc [Suppress F1 in Word/Excel]
autohotkey_recipes [2017/10/23 20:00]
tkbletsc
Line 7: Line 7:
  
 ====== Recipes ====== ====== Recipes ======
-Below are some useful recipes. ​ See also: [[Using AutoHotKey to map keys on the Amtelco KB163 Unified Keyboard]].+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 ===== ===== General =====
Line 20: Line 22:
 #​^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>​ </​file>​
  
 +===== Hold down any key =====
 +<​file>​
 +; do right win key + whatever to hold that key down (if it's listed below)
 +>#​w::​Send {w down}
 +>#​a::​Send {a down}
 +>#​s::​Send {s down}
 +>#​d::​Send {d down}
 +>#​LButton::​Send {LButton down}
 +>#​MButton::​Send {MButton down}
 +>#​RButton::​Send {RButton down}
 +>#​q::​Send {q down}
 +>#​e::​Send {e down}
 +</​file>​
 +
 +===== 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).
 +<​file>​
 +; winamp control (if winamp is running)
 +#If WinExist("​ahk_class BaseWindow_RootWnd"​) ; << this badly named thing refers to winamp
 +Joy1::Send {Media_Play_Pause}
 +Joy4::Send {Media_Stop}
 +Joy6::Send {Media_Next}
 +Joy8::Send {Media_Prev}
 +
 +Joy2::
 +  Send {LWin down}{s down}
 +  SetTimer, WaitForJoy2,​ 30  ; 30ms
 +  return
 +
 +WaitForJoy2:​
 +  if not GetKeyState("​Joy2"​) ​ ; The button has been released.
 +  {
 +    Send {LWin up}{s up}  ; Release the spacebar.
 +    SetTimer, WaitForJoy2,​ off  ; Stop monitoring the button.
 +    return
 +  }
 +  ; Since above didn't "​return",​ the button is still being held down.
 +  Send {LWin down}{s down}  ; Send another Spacebar keystroke.
 +  return
 +
 +Joy3::
 +  Send {LWin down}{a down}
 +  SetTimer, WaitForJoy3,​ 30  ; 30ms
 +  return
 +
 +WaitForJoy3:​
 +  if not GetKeyState("​Joy3"​) ​ ; The button has been released.
 +  {
 +    Send {LWin up}{a up}  ; Release the spacebar.
 +    SetTimer, WaitForJoy3,​ off  ; Stop monitoring the button.
 +    return
 +  }
 +  ; Since above didn't "​return",​ the button is still being held down.
 +  Send {LWin down}{a down}  ; Send another Spacebar keystroke.
 +  return
 +#If ; EndIf
 +</​file>​
 +
 +===== 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.
 +<​file>​
 +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
 +</​file>​
 +
 +===== Extended mouse buttons mapped to media control =====
 +<​file>​
 +XButton2::​Media_Play_Pause
 +XButton1::​Media_Next
 +</​file>​
 +
 +===== Mouse click spam =====
 +Press F7 to toggle auto-clicking over and over as fast as possible.
 +<​file>​
 +i:=0 
 +F7::​SetTimer,​ Spam, % (i:=!i) ? "​10"​ : "​Off"​ ; uses ternary
 +
 +Spam: 
 +   Click
 +   Send {LButton}
 +return
 +</​file>​
 +
 +===== 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 media keys or other key combos that apps can hook without issue.
 +<​file>​
 +; WinAmp+Launchy remaps
 +#​z::​Media_Prev
 +#​x::​Media_Play_Pause
 +#​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>​
 ===== Auto mouse ===== ===== Auto mouse =====
 <​file>​ <​file>​
Line 57: Line 194:
  
 ===== FoxIt ===== ===== FoxIt =====
-The F5 for reload only works if the active file is the most recently opened.  The F6 will switch to a MinTTY session and issue a "make again" command. ​ Obviously this latter one is very specific.+The F5 for reload only works if the active file is the most recently opened.
  
 <​file>​ <​file>​
-; FoxIt keys: F5=reload ​and F6=latex build+; FoxIt keys: F5=reload
 #​IfWinActive,​ ahk_class classFoxitReader #​IfWinActive,​ ahk_class classFoxitReader
-F5::Send ^w!f1 +F5::Send ^w!fr1
-F6:: +
-WinActivate ahk_class mintty +
-Send make again{enter} +
-WinActivate ahk_class classFoxitReader +
-return+
 #​IfWinActive #​IfWinActive
 </​file>​ </​file>​
Line 76: Line 208:
 #​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
 #​IfWinActive ahk_class CabinetWClass #​IfWinActive ahk_class CabinetWClass
 F1::​SoundBeep 110,100 F1::​SoundBeep 110,100
autohotkey_recipes.txt · Last modified: 2017/10/23 20:00 by tkbletsc