Here's a trigger test script I wrote a while back, I've commented where you would put the send keys for demonstration.
Notice the settimers at the top there, took some trial and error to get it right.
Hope it helps
XInput_Init()
Threshold = 64 ; for trigger deadzones
; I recomend the set to 1 here, works better than "ON" flag
SetTimer, TRIGGERWATCH, 1
SetTimer, GOOD_VIBRATIONS, 1
#include xinput.ahk ; the goods
;~ #include JSON.ahk ; Uncomment if JSON is not in your standard lib
return
Esc::
ExitApp ; GTFO
return
TRIGGERSTATE:
; Keys to bind to triggers.
LT_Key = Null
RT_Key = Null
LastRT := LastLT := 0
XInput_Init()
Loop, 4 {
if XInput_GetState(A_Index-1, State)=0 {
LT := json(State,"bLeftTrigger")
RT := json(State,"bRightTrigger")
BT := json(State,"wButtons")
;~ XInput_SetState(A_Index-1, LT*257, RT*257) ; VIBRATE!
}
}
return
TRIGGERWATCH:
gosub TRIGGERSTATE ; redundantly redundant
if (LT > Threshold and RT > Threshold) ;Both triggers are held
vibewait := 10 [color=#FF0000]; this is where the send logic can be placed[/color]
if (LT <= Threshold and RT <= Threshold) ;No triggers are held
vibewait := 9 [color=#FF0000]; and here[/color]
if (LT > Threshold and RT <= Threshold) ;Left trigger is held
vibewait := 4 [color=#FF0000]; and here[/color]
if (LT <= Threshold and RT > Threshold) ;Right trigger is held
vibewait := 8 [color=#FF0000][color=#FF0000]; and here[/color][/color]
Tooltip I'M AN ANOYING TOOLTIP! `n`nLTrigger-%LT% RTrigger-%RT%`n Button Info-%BT%`nvibewait-%vibewait%
return
GOOD_VIBRATIONS:
; these vibration routines were pulled from my WoW health rumble script http://www.autohotkey.com/community/viewtopic.php?t=75729
If vibewait < 9
{
Loop, 4 {
if XInput_GetState(A_Index-1, State)=0 {
XInput_SetState(A_Index-1, vibewait*4000, vibewait*8000) ;MAX 65535
sleep 100
XInput_SetState(A_Index-1, vibewait*8191, vibewait*16383) ;MAX 65535
sleep 250
XInput_SetState(A_Index-1, vibewait*8000, vibewait*4000) ;MAX 65535
sleep 100
XInput_SetState(A_Index-1, vibewait*16383, vibewait*8191) ;MAX 65535 big 16383 low 8191
Sleep 250
XInput_SetState(A_Index-1, vibewait*4000, vibewait*8000) ;MAX 65535
sleep 100
XInput_SetState(A_Index-1, vibewait*8191, vibewait*16383) ;MAX 65535
sleep 250
XInput_SetState(A_Index-1, 0, 0) ;MAX 65535
sleep 2000/vibewait
}
}
}
If vibewait > 9
{
; you have died of dysentery
ISDEAD = YUP!
Loop, 4 {
if XInput_GetState(A_Index-1, State)=0 {
XInput_SetState(A_Index-1, vibewait*10, vibewait*500) ;MAX 65535
sleep 500
XInput_SetState(A_Index-1, vibewait*500, vibewait*1000) ;MAX 65535
sleep 500
XInput_SetState(A_Index-1, vibewait*1000, vibewait*4000) ;MAX 65535
sleep 500
XInput_SetState(A_Index-1, vibewait*4000, vibewait*1000) ;MAX 65535 big 16383 low 8191
Sleep 500
XInput_SetState(A_Index-1, vibewait*1000, vibewait*500) ;MAX 65535
sleep 500
XInput_SetState(A_Index-1, vibewait*500, vibewait*10) ;MAX 65535
sleep 500
XInput_SetState(A_Index-1, 0, 0) ;MAX 65535
sleep 10000/vibewait
XInput_SetState(A_Index-1, vibewait*500, vibewait*10) ;MAX 65535
sleep 500
XInput_SetState(A_Index-1, vibewait*1000, vibewait*500) ;MAX 65535
sleep 500
XInput_SetState(A_Index-1, vibewait*4000, vibewait*1000) ;MAX 65535 big 16383 low 8191
sleep 500
XInput_SetState(A_Index-1, vibewait*1000, vibewait*4000) ;MAX 65535
Sleep 500
XInput_SetState(A_Index-1, vibewait*500, vibewait*1000) ;MAX 65535
sleep 500
XInput_SetState(A_Index-1, vibewait*10, vibewait*500) ;MAX 65535
sleep 500
XInput_SetState(A_Index-1, 0, 0) ;MAX 65535
sleep 10000/vibewait
}
}
return
}
else
{
Loop, 4 {
if XInput_GetState(A_Index-1, State)=0 {
XInput_SetState(A_Index-1, 0, 0) ;MAX 65535
}
}
}
return