Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

BF2: Map Joystick Button to Spot


  • Please log in to reply
5 replies to this topic
Harmor
  • Members
  • 182 posts
  • Last active: Sep 20 2007 05:09 AM
  • Joined: 06 Nov 2005
This Battlefield 2 mini-script I use to spot by pressing a button on my joystick. Normally you have to press 'Q' and hold it down, then click using the Left Mouse button in the Cammo Rose menu.

;
; AutoHotkey      Version: 1.x
; Language:       English
; Platform:       Win9x/NT
;
; Description:
;     1. Press Joystick 6 button "Joy Button 5" to Spot
;
#SingleInstance force
#InstallKeybdHook 
;
; Only run this script when BF2.exe is running in the foreground
;

SetTimer, KeepRunning
return

KeepRunning:

  ; Get the process name of the active window (i.e. Notepad.exe)
  WinGet, szProcessName, ProcessName, A
  if szProcessName = BF2.exe
  {
    Suspend, off
  }
  else
  {
    Suspend, on
  }
return

$^CapsLock::
	ExitApp
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Pressing the Joy6 button will spot
;
$Joy6::
   Send, {q Down}
   Sleep 100
   MouseClick, Left, , , , , D
   sleep 40
   MouseClick, Left, , , , , U
   Send, {q Up}
return

To determine which joystick button to set goto Start -> Control Panel -> Game Controllers. Then goto properties for your joystick and press the appropriate button.

Joy6 is actually "Joy Button 5" when inside BF2 (Battlefield 2 starts counting from 0 rather than the ordinal method that AutoHotKey uses).

EDIT: Updated to use default keybinds (press 'q' to open the cammo rose).

Or you can run this script to test your joystick:
http://www.autohotke...oystickTest.htm
//TODO: Create kewl sig...

  • Guests
  • Last active:
  • Joined: --
Assuming that the Window title for BF2 doesnt change too much between patches this will probably do the job well enough

SetTimer, KeepRunning
return
KeepRunning:
  if WinActive("BF2 (v1.")
  {
     Suspend, off
  }
  else
  {
     Suspend, on
  }
return


Harmor
  • Members
  • 182 posts
  • Last active: Sep 20 2007 05:09 AM
  • Joined: 06 Nov 2005
Updated with some new techniques I learned. See original post.
//TODO: Create kewl sig...

Voidth
  • Guests
  • Last active:
  • Joined: --
My version for having an automatic "Roger" Button (f is the rose in my case)


-------------------------

Send, {f Down}
Sleep 100
DllCall("mouse_event", uint,1, int, -300, int,-30, uint,0, int,0 )
Loop 10 {
MouseClick, left, , , ,
}
Send, {f Up}
return

Harmor
  • Members
  • 182 posts
  • Last active: Sep 20 2007 05:09 AM
  • Joined: 06 Nov 2005
Updated to use default control scheme.
//TODO: Create kewl sig...

Hankparker
  • Members
  • 4 posts
  • Last active: Aug 15 2006 08:12 PM
  • Joined: 13 Aug 2006
Hey im new to macros this would be awesome to use in bf2. How do i apply it to my game? where do i put the file?
CHEVYMAKANE