What about the context mode example on the github repo? Did you try it?
Probably first initialize the library, like described further up - and determine your VID and PID which you want to use.
Code: Select all
#include <AutoHotInterception>
AHIWrapper := new AutoHotInterception()
global AHI := AHIWrapper.GetInstance()
MouseId1:=13
MouseId2:=14
1JoyX:=0
1JoyY:=0
2JoyX:=0
2JoyY:=0
;P1---------------
1Joy1::
GetKeyState, 1JoyX, 1JoyX
GetKeyState, 1JoyY, 1JoyY
1JoyX:= 1JoyX*65535/100
1JoyY:= 1JoyY*65535/100
AHI.SendMouseButtonEventAbsolute(MouseId1, 0, 1, 1JoyX, 1JoyY)
KeyWait 1Joy1
AHI.SendMouseButtonEvent(MouseId1, 0, 0)
Return
1Joy2::
AHI.SendMouseButtonEventAbsolute(MouseId1, 1, 1, 1JoyX, 1JoyY)
KeyWait 1Joy2
AHI.SendMouseButtonEvent(MouseId1, 1, 0)
Return
1Joy3::
AHI.SendMouseButtonEventAbsolute(MouseId1, 2, 1, 1JoyX, 1JoyY)
KeyWait 1Joy2
AHI.SendMouseButtonEvent(MouseId1, 2, 0)
Return
;P2---------------
2Joy1::
GetKeyState, 2JoyX, 2JoyX
GetKeyState, 2JoyY, 2JoyY
2JoyX:= 2JoyX*65535/100
2JoyY:= 2JoyY*65535/100
AHI.SendMouseButtonEventAbsolute(MouseId2, 0, 1, 2JoyX, 2JoyY)
KeyWait 2Joy1
AHI.SendMouseButtonEvent(MouseId1, 0, 0)
Return
2Joy2::
AHI.SendMouseButtonEventAbsolute(MouseId2, 1, 1, 2JoyX, 2JoyY)
KeyWait 2Joy2
AHI.SendMouseButtonEvent(MouseId1, 1, 0)
Return
2Joy3::
AHI.SendMouseButtonEventAbsolute(MouseId2, 2, 1, 2JoyX, 2JoyY)
KeyWait 2Joy2
AHI.SendMouseButtonEvent(MouseId1, 2, 0)
Return
;EXIT---------------
F12::
ExitApp
Code: Select all
#SingleInstance force
#Persistent
#include Lib\AutoHotInterception.ahk
; Initialize AHI
AHI := new AutoHotInterception()
; Mouse
mouseId := AHI.GetMouseId(0x1532, 0x008A) ; Replace with your device VID/PID
; Keyboard
keyboardId := AHI.GetKeyboardId(0x1A2C, 0x2D43) ; Replace with your device VID/PID
; Buffer to store input events
global InputBuffer := []
; Subscribe to all buttons on the specific mouse
AHI.SubscribeMouseButtons(mouseId, true, Func("RecordMouseInput"))
; Subscribe to movement coming from the mouse
AHI.SubscribeMouseMove(mouseId, true, Func("RecordMouseMove"))
; Subscribe to all keys on the specific keyboard
AHI.SubscribeKeyboard(keyboardId, true, Func("KeyEvent"))
; Process delayed inputs
SetTimer, ProcessDelayedInputs, 1 ; Check for delayed inputs every 1ms
return
; Mouse
RecordMouseInput(button, state) {
global InputBuffer
InputBuffer.Push({Type: "MouseButton", Timestamp: A_TickCount, Button: button, State: state})
}
RecordMouseMove(x, y) {
global InputBuffer
InputBuffer.Push({Type: "MouseMove", Timestamp: A_TickCount, X: x, Y: y})
}
; Keyboard
KeyEvent(code, state){
global InputBuffer
InputBuffer.Push({Type: "Key", Timestamp: A_TickCount, Code: code, State: state})
}
ProcessDelayedInputs:
delay := 7000 ; Set the delay to 0.5 seconds (500ms)
while (InputBuffer.MaxIndex() > 0 && A_TickCount - InputBuffer[1].Timestamp >= delay) {
input := InputBuffer.RemoveAt(1) ; Remove and get the first input in the buffer
if (input.Type == "MouseMove") {
AHI.Instance.SendMouseMove(mouseId, input.X, input.Y)
} else if (input.Type == "MouseButton") {
AHI.Instance.SendMouseButtonEvent(mouseId, input.Button, input.State)
} else if (input.Type == "Key") {
AHI.Instance.SendKeyEvent(keyboardId, input.Code, input.State)
}
}
return
^Esc::
ExitApp