You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: AHK v1/Interception Subscription Mode Example.ahk
+9-8
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,20 @@
1
1
; Demonstrates Interception Subscription Mode with TapHoldManager
2
2
#SingleInstance force
3
3
; Use these includes if you placed the contents of the TapHoldManager and AutoHotInterception Lib folders in the AHK lib folder (My Documents\AutoHotkey\Lib)
4
-
#include<AutoHotInterception>
5
-
#include<InterceptionTapHold>
6
-
#include<TapHoldManager>
4
+
;#include <AutoHotInterception>
5
+
;#include <InterceptionTapHold>
6
+
;#include <TapHoldManager>
7
7
8
8
; Use these includes if you placed the contents of the TapHoldManager and AutoHotInterception Lib folders in a lib folder next to this script
9
9
; ie copy the AutoHotInterception Lib folder into the TapHoldManager Lib folder
; Exmaple of Context Specific hotkeys (Only applies to a certain window)
3
+
; If the library files are in a subfolder called Lib next to the script, use this
4
+
#includeLib\TapHoldManager.ahk
5
+
; If you placed all the library files in your My Documents\AutoHotkey\lib folder, use this
6
+
;#include <TapHoldManager>
7
+
8
+
thm := TapHoldManager(,,,,"ahk_exe notepad.exe") ; with window parameter set here, default window criteria that will be set for all sub-created hotkeys under this manager object is notepad
9
+
thm.Add("1", MyFunc1)
10
+
thm.Add("2", MyFunc2)
11
+
thm.Add("3", MyFunc3,,,,,"ahk_class WordPadClass") ; this hotkey's window criteria will be WordPad (instead of manager object's previously passed-in notepad default)
; Demonstrates Interception Subscription Mode with TapHoldManager
5
+
6
+
; Use these includes if you placed the contents of the TapHoldManager and AutoHotInterception Lib folders in the AHK lib folder (My Documents\AutoHotkey\Lib)
7
+
; #include <AutoHotInterception>
8
+
; #include <InterceptionTapHold>
9
+
; #include <TapHoldManager>
10
+
11
+
; Use these includes if you placed the contents of the TapHoldManager and AutoHotInterception Lib folders in a lib folder next to this script
12
+
; ie copy the AutoHotInterception Lib folder into the TapHoldManager Lib folder
HotIfWinactive ; restores hotkey window context to default
76
+
}
77
+
78
+
; Turns On/Off hotkeys (should be previously declared) // state is either "1: On" or "0: Off"
79
+
SetState(state){
80
+
; "state" under this method context refers to whether the hotkey will be turned on or off, while in other methods context "state" refers to the current activity on the hotkey (whether it's pressed or released (after a tap or hold))
81
+
if (this.window)
82
+
HotIfWinactive this.window
83
+
84
+
state := (state ? "On" : "Off")
85
+
Hotkey this.prefixes this.keyName, state
86
+
if (this.keyName ~= "i)^\d*Joy"){
87
+
Hotkey this.keyName " up", state
88
+
} else {
89
+
Hotkey this.prefixes this.keyName " up", state
90
+
}
91
+
92
+
if (this.window)
93
+
HotIfWinactive
94
+
}
95
+
96
+
; For correcting a bug in AHK
97
+
; A joystick button hotkey such as "1Joy1 up::" will fire on button down, and not on release up
98
+
; So when the button is pressed, we start a timer which checks the actual state of the button using GetKeyState...
99
+
; ... and when it is actually released, we fire the up event
0 commit comments