;----------------------------------------------------------------------------------------------------------------------- ; X2 ; Trigger fires normal weapons, Pinky+Trigger fires ION cannons ; More info for when double-colon binding works but Send does not: ; http://www.autohotkey.com/forum/topic15428.html ;----------------------------------------------------------------------------------------------------------------------- #IfWinActive, ahk_class X2 *Joy1:: if (!Firing && GetKeyState("Joy6")) { SetWeaponsGroup(2) } EnableFiring(true) Return ;*x:: ; Return ;*x up:: ; Return #IfWinActive InitX2Vars() { ; Must call this function on script init global MaxWeaponsGroup := 2 WeaponsGroup := 1 Firing := false TriggerPollInterval := 200 NumPresses := 0 WasFiring := false SleepDelay := 5 ;MsgBox ,,, NewGroup: %newGroup%, WeaponsGroup: %WeaponsGroup%, NumPresses: %NumPresses% } EnableFiring(state) { global if (Firing = state) { return } Firing := state if (state) { Send {Blind}{LControl DownTemp} Sleep %SleepDelay% SetTimer TriggerMonitor, %TriggerPollInterval% } else { SetTimer TriggerMonitor, off Send {Blind}{LControl Up} Sleep %SleepDelay% } } TriggerMonitor: if (!GetKeyState("Joy1")) { EnableFiring(false) SetWeaponsGroup(1) } else { if (GetKeyState("Joy6")) { SetWeaponsGroup(2) } else { SetWeaponsGroup(1) } } Return SetWeaponsGroup(newGroup) { global if (WeaponsGroup = newGroup) { return } WasFiring := Firing EnableFiring(false) if (newGroup > WeaponsGroup) { NumPresses := (newGroup - WeaponsGroup) } else { NumPresses := ((MaxWeaponsGroup - WeaponsGroup) + 1 + newGroup) ; +1 is to skip the blank group } ; Note: Must not switch both weapon slots to "empty" at same time; otherwise recharge will be required Loop %NumPresses% { Send {Blind}{1 DownTemp} Sleep %SleepDelay% Send {Blind}{1 Up} Sleep %SleepDelay% } Loop %NumPresses% { Send {Blind}{2 DownTemp} Sleep %SleepDelay% Send {Blind}{2 Up} Sleep %SleepDelay% } WeaponsGroup := newGroup EnableFiring(WasFiring) Return }