Code: Select all
; AutoHotkey Version: 1.x
; Language: English
; Platform: Win9x/NT/xp
;
; Only run this script when bf2.exe is running in the foreground
;
#SingleInstance force
#InstallKeybdHook
#InstallMouseHook
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Global Variabless ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Joystick to use (1st Joystick is 1, 2nd Joystick is 2, etc...)
;
JoystickNumber = 1
;
; The delay in milliseconds to check state of HAT control
;
HatDelay = 1
;
; Amount to move mouse by
HatMoveBy = 10
;
; Speed to move mouse at, 0 - 100
;
HatMoveSpeed = 0
;
; MouseLook key
;
HatMouseLookOn = {RCTRL Down}
HatMouseLookOff = {RCTRL Up}
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Auto Execution Section - OnLoad ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
SetTimer, KeepRunning ; Only run this script while bf2 is running
;
; Only start the timer for using the Joystick's POV as a Mouse in BF2
; if %JoystickNumber% has a POV Control
;
GetKeyState, JoyInfo, %JoystickNumber%JoyInfo
IfInString, JoyInfo, P ; Joystick has POV control
{
SetTimer, HatMouse, %HatDelay%
}
return
;
; KeepRunning Timer execution Section: Suspend this script if BF2.exe is not actively running
;
KeepRunning:
WinGet, szProcessName, ProcessName, A
if szProcessName = bf2.exe
{
Suspend, off
}
else
{
Suspend, on
}
return
;
; HatMouse Timer execution Section: Use the Joystick's POV to mouselook
;
HatMouse:
GetKeyState, JoyPOV, %JoystickNumber%JoyPOV
if JoyPOV = -1 ; No angle.
{
Send %HatMouseLookOff%
return
}
else
{
Send %HatMouseLookOn%
}
if JoyPOV = 0 ; Up
{
MouseMove,0,-%HatMoveBy%,%HatMoveSpeed%,R
}
else if JoyPOV = 4500 ; up/right
{
MouseMove,%HatMoveBy%,-%HatMoveBy%,%HatMoveSpeed%,R
}
else if JoyPOV = 9000 ; right
{
MouseMove,%HatMoveBy%,0,%HatMoveSpeed%,R
}
else if JoyPOV = 13500 ; right/down
{
MouseMove,%HatMoveBy%,%HatMoveBy%,%HatMoveSpeed%,R
}
else if JoyPOV = 18000 ; down
{
MouseMove,0,%HatMoveBy%,%HatMoveSpeed%,R
}
else if JoyPOV = 22500 ; down/left
{
MouseMove,-%HatMoveBy%,%HatMoveBy%,%HatMoveSpeed%,R
}
else if JoyPOV = 27000 ; left
{
MouseMove,-%HatMoveBy%,0,%HatMoveSpeed%,R
}
else if JoyPOV = 31500 ; left/up
{
MouseMove,-%HatMoveBy%,-%HatMoveBy%,%HatMoveSpeed%,R
}
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Press Joy4 to say "I'm sorry" using the Cammo Rose while flying ;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Joy4::
Send, {q Down}
Sleep 200
DllCall("mouse_event", uint,1, int,300, int,10, uint,0, int,0 )
Sleep 40
MouseClick, Left, , , , , D
sleep 40
MouseClick, Left, , , , , U
Send, {q Up}
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; Press Joy5 to spot a target directly in front of you using the Cammo Rose while flying ;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Joy5::
Send, {q Down}
Sleep 100
MouseClick, Left, , , , , D
sleep 40
MouseClick, Left, , , , , U
Send, {q Up}
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;; camera positions fly by - F12 / F9 - cockpit ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Joy10::
{
Send, {F12 down}
Sleep 30
Send, {F12 up}
SetTimer, WaitForButtonUp7, 25
}
return
WaitForButtonUp7:
if GetKeyState("Joy8")
Return
SetTimer, WaitForButtonUp7, off
Send, {F9 down}
Sleep 30
Send, {F9 up}
Sleep 30
Send, {F9 down}
Sleep 30
Send, {F9 up}
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; camera positions shase rear - F11 / F9 - cockpit ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Joy3::
{
Send, {F11 down}
Sleep 30
Send, {F11 up}
SetTimer, WaitForButtonUp8, 25
}
return
WaitForButtonUp8:
if GetKeyState("Joy3")
Return
SetTimer, WaitForButtonUp8, off
Send, {F9 down}
Sleep 30
Send, {F9 up}
Sleep 30
Send, {F9 down}
Sleep 30
Send, {F9 up}
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; map ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Joy9::
{
Send, {m down}
Sleep 30
Send, {m up}
SetTimer, WaitForButtonUp9, 25
}
return
WaitForButtonUp9:
if GetKeyState("Joy9")
Return
SetTimer, WaitForButtonUp9, off
Send, {m down}
Sleep 30
Send, {m up}
Sleep 30
return