Hi, I'm the guy using ahk wrapper to support crt lightguns.
I'm moving to Autohotinterception as seems pretty much easier to code, but I need some help, I'm graphist, and I may have some basic errors coding, any help would be apreciated.
crt guns are absolute coords mouse devices, and have the same pid and vid, but they don't track over dark colors, so I use a program that flasher the screen for a custom amount of ms.
I use a supposed precision timer, that's why I write sleep().
So The main goal is to delay the trigger: I block the real click input, I simulate the flasher key, and then I simulate the click and I control its duration too, to be inside the flashing time ( important in some games).
I'm not very sure how to get all the devices id with the same hid pin, this part is not working in my code yet.
I also wanted to block mouse movement and only update it when the simulated click is down. This is working, but maybe not the best way.
On the otherhand I tried to send right click instead of left click whenever aiming offscreen. I'm getting x=0 y=0, but couldn't get it work
Basically I'm doing an exe that I launch with any game that needs it so I use a bat:
Code: Select all
Start game.exe
Start TriggerDelayer.exe 15 60 block offscreen
TriggerDelayer.exe:
Code: Select all
#SingleInstance force
#Persistent
#NoTrayIcon
#SingleInstance, Force
#NoEnv
;#Warn, All, OutputDebug
#MaxHotkeysPerInterval 255
#MaxThreads 255
SetKeyDelay -1
SetBatchLines -1
SetWorkingDir %A_ScriptDir%
Process, Priority,,High
#include <AutoHotInterception>
triggerdelay = %1%
triggerlength = %2%
;global triggerdelay := 15
;global triggerlength := 60
NumberOfParameters = %0%
Loop, %NumberOfParameters%
{
Parameter :=%A_Index%
if Parameter = offscreen
reload = offscreen
if Parameter = block
tracking = block
}
global VID := 0x0B9A, PID := 0x016A;STRANGE FOR ME, I HAVE TO SET ALL GLOBAL VARS?
global triggerdelay := triggerdelay
global triggerlength := triggerlength
global reload := reload
global tracking := tracking
InterceptionWrapper := new AutoHotInterception()
global Interception := InterceptionWrapper.GetInstance()
DeviceList := InterceptionWrapper.GetDeviceList(true)
if (!DeviceList.Length()){
msgbox Device List Check failed
ExitApp
}
;Loop 20 { NOT USED ATM MAYBE USEFUL TO GET THE DEVICES?
; i := 1 + A_Index
; dev := DeviceList[i]
; if (!IsObject(dev)){
; continue
; }
; ;MsgBox % i
;}
global Gun1 := Interception.GetDeviceId(true, VID, PID); TESTING ONLY WITH ONE GUN ATM
Interception.SubscribeMouseButton(Gun1, 0, true, Func("ButtonEvent"))
if tracking = block
Interception.SubscribeMouseMoveAbsolute(Gun1, true, Func("MouseEvent"))
ButtonEvent(state){
Gun := Interception.GetDeviceId(true, VID, PID)
;ToolTip State: %state% device: %Gun%
if(state=1)
triggerDelay(Gun)
}
triggerDelay(Gun){
If (Gun = Gun1)
flashkey = a
Else
flashkey = k
send, %flashkey%
sleep(triggerdelay)
if tracking = block
Interception.SubscribeMouseMoveAbsolute(Gun, false, Func("MouseEvent"))
if (reload = offscreen && x=0 && y=0); HERE RELOAD, X AND Y VARS DONT WORK
{
Interception.SendMouseButtonEvent(Gun,1, 1)
sleep(triggerlength)
if tracking = block
Interception.SubscribeMouseMoveAbsolute(Gun, true, Func("MouseEvent"))
Interception.SendMouseButtonEvent(Gun,1, 0)
}
else
{
Interception.SendMouseButtonEvent(Gun,0, 1)
sleep(triggerlength)
if tracking = block
Interception.SubscribeMouseMoveAbsolute(Gun, true, Func("MouseEvent"))
Interception.SendMouseButtonEvent(Gun,0, 0)
}
}
MouseEvent(x, y){
ToolTip % "x:" x "`ny:" y
}
F12::
ExitApp