AutoHotInterception/Context Example.ahk

42 lines
841 B
AutoHotkey
Raw Normal View History

2018-03-07 20:46:37 +00:00
#SingleInstance force
#Persistent
#include Lib\AutoHotInterception.ahk
VID := 0x04F2, PID := 0x0112
2018-03-28 19:39:29 +00:00
InterceptionWrapper := new AutoHotInterception()
global Interception := InterceptionWrapper.GetInstance()
2018-03-07 20:46:37 +00:00
2018-03-28 19:39:29 +00:00
devices := InterceptionWrapper.GetDeviceList()
if (!devices.Length()){
2018-03-07 20:46:37 +00:00
msgbox Device List Check failed
ExitApp
}
2018-03-28 19:39:29 +00:00
keyboardId := Interception.GetDeviceId(false, VID, PID)
2018-03-07 20:46:37 +00:00
2018-03-28 19:39:29 +00:00
result := Interception.SetContextCallback(keyboardId, Func("SetKb1Context"))
2018-03-07 20:46:37 +00:00
if (result != -1){
msgbox Subscribe failed
ExitApp
}
return
SetKb1Context(state){
global isKeyboard1Active
2018-03-07 21:06:24 +00:00
Sleep 0 ; We seem to need this for hotstrings to work, not sure why
2018-03-07 20:46:37 +00:00
isKeyboard1Active := state
}
#if isKeyboard1Active
::aaa::JACKPOT
1::
ToolTip % "KEY DOWN EVENT @ " A_TickCount
return
1 up::
ToolTip % "KEY UP EVENT @ " A_TickCount
return
#if
^Esc::
ExitApp