Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

BF2 MACROS (SUMMARY) - post all working macros here please


  • Please log in to reply
1915 replies to this topic
Lanser
  • Members
  • 20 posts
  • Last active: Feb 01 2007 09:21 PM
  • Joined: 24 Mar 2006
Seeing as JoyToKey has been mentioned there are additional things you could put at the start of your script to launch BF2, start JoyToKey and if any of you have the Logitech G15 keyboard you can launch your LCD Displays BF2 Mod with only the BF2 display running, the possibilities are endless provided you're willing to experiment ...

G15Applets = C:\Program Files\Logitech\G-series Software\Applets\
BF2G15Modpath = C:\Program Files\BF2G15Mod\
GameName = bf2.exe						; Set exe name here
GamePath = C:\Program Files\EA GAMES\Battlefield 2\
JTKpath = C:\Program Files\JoyToKey\
JTKexe = JoyToKey.exe
Pskill = C:\Program Files\pstools\pskill.exe          ; uses Pskill from http://www.sysinternals.com/Utilities/PsTools.html

#NoEnv									; prevents empty variables from being looked up
#SingleInstance force
#InstallKeybdHook
#InstallMouseHook
SetKeyDelay, 50, 50						; NB: Once 
Gosub, LaunchJoyTokey
Gosub, LaunchGame
Gosub, BF2G15MODstart
SetTimer, KeepRunning					; Only run this script when {BF2.exe} is running in the foreground
OnExit, ExitSub
Return

; Exit
ExitSub:
  ; Kill the BF2 G15 Mod (restart default applets) and JoyToKey on exit
  Gosub, BF2G15MODterm
  Run, %Pskill% %JTKexe%
  Sleep 10
ExitApp

LaunchGame:
  Process, Exist, %GameName%,         	;Check if Game is alReady Running to not open it Multiple times
  If Errorlevel <> 0
    Return
  Else
    Run, %GameName%, %GamePath%
Return

LaunchJoyTokey:
  Process, Exist, %JTKexe%,         	;Check if JoyToKey is alReady Running to not open it Multiple times
  If Errorlevel <> 0
    Return
  Else
    Run, %JTKpath%%JTKexe% BF2, %JTKpath%
Return

;#############################################################################
;### Logitech G15 Keyboard related ###########################################
;#############################################################################

$#!b::
   Goto, BF2G15MODstart
   
$#+b::
   Goto, BF2G15MODterm  

BF2G15MODstart:
   Run, %Pskill% LCDClock.exe
   Run, %Pskill% LCDCountdown.exe
   Run, %Pskill% LCDMedia.exe
   Run, %Pskill% LCDPOP3.exe
   Run, %BF2G15Modpath%BF2 LCD.exe
Return

BF2G15MODterm:
   Run, %Pskill% "BF2 LCD.exe"			; Must be in quotes or it won't terminate.
   Run, %G15Applets%LCDClock.exe
   Run, %G15Applets%LCDCountdown\LCDCountdown.exe
   Run, %G15Applets%LCDMedia.exe
   Run, %G15Applets%LCDPop3\LCDPOP3.exe
Return

; --------------------------------------------------------------------------------



Lanser
  • Members
  • 20 posts
  • Last active: Feb 01 2007 09:21 PM
  • Joined: 24 Mar 2006
Crouch / Toggle Crouch

In some situations I'd like the Crouch to be held down. So the following allowing your Crouch key to act as normal but if you double tap the crouch key it will hold Crouch until you press it again ....


~LCtrl up::								;use LCtrl "up" so it doesn't get triggered when you hold ctrl
  Goto, Crouch

Crouch:
  ; Changed: Trigger was changed to "~LCtrl" as ~ allows normal operation of key.
  If (a_tickCount-lasttime < 400)   	;Check when we released ctrl the last time if < 400ms initiate Crouch
  {
    Loop
    {
      Send, {LCtrl down}				; Initiate 'Crouch'
      If IsKeyPressed("LCtrl")			; Check if 'LCtrl' pressed. If pressed & released, Break loop.
        Send, {LCtrl up}				; Release 'Crouch'
      Break
    }
  }
  lasttime:=a_tickCount
Return

IsKeyPressed(v_KeyName)
  ; Returns 1 if %v_KeyName% is currently being pressed, otherwise 0
  {
    GetKeyState, state, %v_KeyName%, P
    If state = D  ; The key has been pressed
    {
      Return 1
    }
    Return 0
  }

You'll notice it uses your "IsKeyPressed()" function Harmor. Nice one, saves quiet a few lines in a large script.

Harmor
  • Members
  • 182 posts
  • Last active: Sep 20 2007 05:09 AM
  • Joined: 06 Nov 2005

Voice Recognition software to issue Commo Rose commands automatically. So you say "Sorry", "Need Repairs" etc out loud and the Commo Rose command is played out for you.


WOW...that's kewl using Voice Recognition. I thought it was playing 'text' like how Ventrillo works.

You'll notice it uses your "IsKeyPressed()" function Harmor. Nice one, saves quiet a few lines in a large script.


Hehe...it looked familiar. You know you can do:

if GetKeyState("KeyName" [, "Mode"])
...


I really love AutoHotkey. Sometimes I will write a AutoHotkey script instead of writing it using Visual Studio!!! When I compile it and make an icon with it some people don't even know that its AutoHotkey!!!!

So nice.

I'm doing some tests with PixelSearch right now...I'll let you know the status sometime tomorrow.
//TODO: Create kewl sig...

Lanser
  • Members
  • 20 posts
  • Last active: Feb 01 2007 09:21 PM
  • Joined: 24 Mar 2006
Tank/APC Vehicle Views

I guess we've all been there, you're within close proximity of a flag capturing it and despite the fact you have trustworthy squadmates surrounding you as well capturing the flag some sneaky Special Ops guy with his packs of C4 walks up to you in plain sight and turns your tank or APC into a smouldering carcass. Well here's a little idea i had originally implemented on my Nostromo N52. I call it a "Point Of View scan". Press and Hold 'Windows' key and some other key of your choice, as long you as you have 'Windows' held down your view will rapidly switch between Chase Front (F11) and Chase rear (F10) allowing you to see sneaky approaching Spec Ops or Engineers and clear out of there ...

KeySleep1 = 100							; Ideal Sleep time for BF2 commands (check?, SetKeyDelay influence?)

$#1::
  Goto, ViewInsidePOV        ; Commence Point of View Scan or just F9

IsKeyReleased(v_KeyName)
  ; Returns 1 if %v_KeyName% has been released, otherwise 0
  {
    GetKeyState, state, %v_KeyName%, P
    If state = U  ; The key has been released
    {
      Return 1
    }
    Return 0
  }

ViewFront:
  VehicleView(11)						; Switch to Chase Front
Return

ViewInside:
  VehicleView(9)						; Switch to internal view
  VehicleView(9)
Return

ViewRear:
  VehicleView(10)						; Switch to Chase Rear
Return

ViewInsidePOV:
  ; View inside vehicle else if 'Win' held commence a forward and rear scan until 'Win' released.
  Gosub, ViewInside
  Sleep 800
  Loop
  {
    Sleep, 10
    If IsKeyReleased("LWin") 			; Check if 'LWin' key has been released, if so Break out of the loop.
      Break
    ; Commence POV Point of View Scan.
    Gosub, ViewFront
    Sleep 800
    Gosub, ViewRear
    Sleep 800
  }
  Goto, ViewInside
Return									; needed? cosmetic probably.

VehicleView(v_iView)
  ; Change Vehicle view by pressing function key F9-F11 %v_iView%
  {
    If( v_iView > 8 and v_iView < 12)
    {
      Send, {F%v_iView% Down}
      Sleep %KeySleep1%
      Send, {F%v_iView% Up}
      Sleep %KeySleep1%
    }
  Else
    Send, @huh????%v_iPosition%
  Sleep 50
  }


Of course you can edit the Hotkey trigger to whatever you wish. When I started using AutoHotkey to improve my binding I moved my windows key to where my Caps Lock would normally be and key '1' is the middle thumb button on my Logitech MX1000 mouse. I find myself using Windows and Shift key all the time now, it effectively triples the functions of each of your mouse buttons. So my mouse is doing everything now from answering Yes/No, displaying Map, changing Mini-Map, displaying scoreboard, activating VOIP, issuing preset Commo Rose commands etc, etc.

Lanser
  • Members
  • 20 posts
  • Last active: Feb 01 2007 09:21 PM
  • Joined: 24 Mar 2006

WOW...that's kewl using Voice Recognition. I thought it was playing 'text' like how Ventrillo works.


Yeah it was one of those simple ideas that blossomed into a nice working concept. If you're interested you can try out Shoot 1.6.4 for starters as per the TotalBF2 link above but several months back I found a way better Voice Recogition front end called "Voice Activated Commands", VAC http://www.dwvac.com/. I'm going to put up a new thread about it on TotalBF2 soon.

I really love AutoHotkey. Sometimes I will write a AutoHotkey script instead of writing it using Visual Studio!!! When I compile it and make an icon with it some people don't even know that its AutoHotkey!!!!


I love it too. I think AutoHotkey is a fantastic idea, really useful, so flexible, seemingly endless applications for it. Many thanks to Chris. If you make any progress with PixelSearch I'd be glad to know. Keep up the good work. I liked your "Weapon Compare" page too on TotalBF2, I made a comment there.

Anyway people keep the BF2 ideas coming.

Harmor
  • Members
  • 182 posts
  • Last active: Sep 20 2007 05:09 AM
  • Joined: 06 Nov 2005

Tank/APC Vehicle Views


Hmm...I wonder if switching to the different seats in the APC would work too? You know, {F1}, {F2}, {F3}, {F4}, {F5} ...

What do you think?

;
; Returns 1 if %a_szKeyName% is not being pressed, otherwise 0
;
IsKeyReleased(a_szKeyName)
{
   GetKeyState, state, %a_szKeyName%, P
   If state = U  ; The key is not being pressed
   {
      Return 1
   }
   Return 0
} 

$LWin::
  iSeatCount = 1
  Loop
  {
    ; Check if 'LWin' key has been released, if so Break out of the loop.
    If IsKeyReleased("LWin")          
      Break
    if iSeatCount > 5
       iSeatCount = 1
   VehicleSeat(iSeatCount)
   iSeatCount++
    Sleep, 800
  }
Return                           ; needed? cosmetic probably.
;
; Change to Vehicle seat %a_iSeatNumber* function key F1-F5
;
VehicleSeat(a_iSeatNumber)
{
   If( a_iSeatNumber > 0 and a_iSeatNumber < 6)
   {
      Send, {F%a_iSeatNumber% Down}
      Sleep 100
      Send, {F%a_iSeatNumber% Up}
      Sleep 100
   }
   Sleep 50
}

By pressing the LWin key it presses {F1}, {F2}, ... and then stops when you release LWin. To switch back to {F1} you just tap LWin and it will press {F1}.


Instead of using the local variable iSeatCount I tried to use:

iSeatCount := mod(%a_index%,5) + 1
VehicleSeat(iSeatCount)
but it didn't work...any idea why?
//TODO: Create kewl sig...

Harmor
  • Members
  • 182 posts
  • Last active: Sep 20 2007 05:09 AM
  • Joined: 06 Nov 2005

Tank/APC Vehicle Views


I made an modification to your script. Instead of using the LWin to activate I use Shift+W. Now you're probably thinking to yourself, why Shift+W? Well this way you can press Shift+W while moving and the camera will cycle back and forth every 0.5 seconds...then to switch back to normal view you just deselect 'w'...and then tap it again to stop moving forward. Since you can't change views while on foot it won't affect your play.

Also notice that I'm checking for the release of the key more often. I want to switch back to {F9} cockpit view as soon as possible, that's why I make more checks instead of waiting til the camera is finished cycling though both {F10} and {F11}.

;
; AutoHotkey      Version: 1.1.2878+
; Language:       English
; Platform:       Win9x/NT
;
;
; Only run this script when bf2.exe is running in the foreground
;
#SingleInstance force
#InstallKeybdHook 
#InstallMouseHook


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 Ctrl+V while BF2 is active
;
$^v::
	Sleep 200
   SetKeyDelay, 30,30
	Send,  {Space}%clipboard%
   SetKeyDelay, 0
return
;
; Hold down Shift+w briefly to start, then release the shift key, 
; but keep holding down 'w' to keep the camera switching.
; When you release 'w' the camera will go back to {F9} view
; To stop moving forward just tap the 'w' key again
;
$+w:: 
  ; View inside vehicle else if 'Win' held commence a forward and rear scan until 'w' released.
  Loop
  {
    Sleep, 10
    If IsKeyReleased("w")   
      Break
    VehicleViewFront()
    If IsKeyReleased("w")
      Break
    Sleep, 500
    If IsKeyReleased("w")
      Break
    VehicleViewRear()
    If IsKeyReleased("w")
      Break
    Sleep, 500
  }
  VehicleViewInside()
Return

; Returns 1 if %a_szKeyName% is not being pressed, otherwise 0
;
IsKeyReleased(a_szKeyName)
{
   GetKeyState, state, %a_szKeyName%, P
   If state = U  ; The key is not being pressed
   {
      Return 1
   }
   Return 0
} 

VehicleView(v_iView)
  ; Change Vehicle view by pressing function key F9-F11 %v_iView%
  {
    If( v_iView > 8 and v_iView < 12)
    {
      Send, {F%v_iView% Down}
      Sleep 100
      Send, {F%v_iView% Up}
      Sleep 100
    }
  Sleep 50
  } 

VehicleViewFront()
{
  VehicleView(10)
}

VehicleViewRear()
{
  VehicleView(11)
}

VehicleViewInside()
{
  VehicleView(9)
  VehicleView(9)
}



Here's a version that uses XButton1 on your mouse instead:

;
; AutoHotkey      Version: 1.1.2878+
; Language:       English
; Platform:       Win9x/NT
;
;
; Only run this script when bf2.exe is running in the foreground
;
#SingleInstance force
#InstallKeybdHook 
#InstallMouseHook


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 Ctrl+V while BF2 is active
;
$^v::
	Sleep 200
   SetKeyDelay, 30,30
	Send,  {Space}%clipboard%
   SetKeyDelay, 0
return
;
; Hold down XButton1 button to start cycling though Rear and Front
; views.  Release XButton1 and it will return you to cockpit view
; (with no cockpit)
;
$XButton1:: 
  Loop
  {
    Sleep, 10
    If IsKeyReleased("XButton1")   
      Break
    VehicleViewFront()
    If IsKeyReleased("XButton1")
      Break
    Sleep, 500
    If IsKeyReleased("XButton1")
      Break
    VehicleViewRear()
    If IsKeyReleased("XButton1")
      Break
    Sleep, 500
  }
  VehicleViewInside()
Return

; Returns 1 if %a_szKeyName% is not being pressed, otherwise 0
;
IsKeyReleased(a_szKeyName)
{
   GetKeyState, state, %a_szKeyName%, P
   If state = U  ; The key is not being pressed
   {
      Return 1
   }
   Return 0
} 

VehicleView(v_iView)
  ; Change Vehicle view by pressing function key F9-F11 %v_iView%
  {
    If( v_iView > 8 and v_iView < 12)
    {
      Send, {F%v_iView% Down}
      Sleep 100
      Send, {F%v_iView% Up}
      Sleep 100
    }
  Sleep 50
  } 

VehicleViewFront()
{
  VehicleView(10)
}

VehicleViewRear()
{
  VehicleView(11)
}

VehicleViewInside()
{
  VehicleView(9)
  VehicleView(9)
}

//TODO: Create kewl sig...

Lanser
  • Members
  • 20 posts
  • Last active: Feb 01 2007 09:21 PM
  • Joined: 24 Mar 2006
Vehicle Position Switching

Hey Harmor,

I see you've probably solved your own question but I'll offer you what I have anyway. I hadn't considered using position scan within the vehicle but nice idea :). I was using a Hotkey however which used a function to either Cycle Up or Cycle Down through Vehicle Positions. So took that a step further to have a Vehicle Position Cycle. Can't confirm it works as I'm away from my BF2 PC for a week but I did a trial in Notepad and seems ok. Just hope I've copied n pasted all the relevant lines.

IsKeyReleased(v_KeyName)
  ; Returns 1 if %v_KeyName% has been released, otherwise 0
  {
    GetKeyState, state, %v_KeyName%, P
    If state = U  ; The key has been released
    {
      Return 1
    }
    Return 0
  }

ViewFront:
  VehicleView(11)						; Switch to Chase Front
Return

ViewInside:
  VehicleView(9)						; Switch to internal view
  VehicleView(9)
Return

ViewRear:
  VehicleView(10)						; Switch to Chase Rear
Return

ViewInsidePOV:
  ; View inside vehicle else if 'Win' held commence a forward and rear scan until 'Win' released.
  Gosub, ViewInside
  Sleep 800
  Loop
  {
    Sleep, 10
    If IsKeyReleased("LWin") 			; Check if 'LWin' key has been released, if so Break out of the loop.
      Break
    ; Commence POV Point of View Scan.
    Gosub, ViewFront
    Sleep 800
    Gosub, ViewRear
    Sleep 800
  }
  Goto, ViewInside
Return									; needed? cosmetic probably.

VehicleView(v_iView)
  ; Change Vehicle view by pressing function key F9-F11 %v_iView%
  {
    If( v_iView > 8 and v_iView < 12)
    {
      Send, {F%v_iView% Down}
      Sleep %KeySleep1%
      Send, {F%v_iView% Up}
      Sleep %KeySleep1%
    }
  Else
    Send, @huh????%v_iPosition%
  Sleep 50
  }

VehiclePositionCycle:
  ; Cycle up through Vehicle postions F1-F6 if 'Win' held until 'Win' released.
  Gosub, ViewInside
  Sleep 800
  Loop
  {
    Sleep, 10
    If IsKeyReleased("LWin") 			; Check if 'LWin' key has been released, if so Break out of the loop.
      Break
    ; Commence upward cycle of Vehicle Positions, timer might need increase/decrease??.
    Gosub, VehicleCycleUp
    Sleep 800
    ;Gosub, ViewRear
    ;Sleep 800
  }
  ;Goto, ViewInside
  VehiclePosition(1)					; This bit needs to be verified to ensure switches correctly in BF2
  ;Msgbox, Hello I've ended the position cycle. Back to Postiton: %v_iPosition%   ; %v_iPosition% wasn't declared "Global" incorrct value held
Return	  

#T::
   Goto, VehicleCycleUp   ; Hotkey only for testing, assign better key
   
#G::
   Goto, VehicleCycleDown   ; Hotkey only for testing, assign better key

$#J::
   Goto, VehiclePositionCycle    ; Hotkey only for testing, assign better key 
   
~E::v_iPosition = 1						; Need to set default vehicle position on enter/exit vehicle??  
   
VehicleCycleUp:
  If( v_iPosition > 0 and v_iPosition < 6)
  {
    v_iPosition++						; Increment position by 1
    VehiclePosition(v_iPosition)
    ;Msgbox, Postiton is: %v_iPosition% 
  }
  Else If (v_iPosition > 5)
  {
	v_iPosition = 1
	VehiclePosition(v_iPosition)
	;Msgbox, Postiton is: %v_iPosition%
  }
Return

VehicleCycleDown:
  If( v_iPosition > 1 and v_iPosition < 7)
  {
    v_iPosition--						; Decrement position by 1
    VehiclePosition(v_iPosition)
	;Msgbox, Postiton is: %v_iPosition% 
  }
  Else If (v_iPosition < 2)
  {
	v_iPosition = 6
	VehiclePosition(v_iPosition)
	;Msgbox, Postiton is: %v_iPosition%
  }
Return  

VehiclePosition(v_iPosition)
; Change Vehicle position by pressing function key F1-F6 %v_iPosition%
{
  If( v_iPosition > 0 and v_iPosition < 7)
  {
    ; Audible notification?   
    Send, {F%v_iPosition% Down}
    Sleep %KeySleep1%
    Send, {F%v_iPosition% Up}
    Sleep %KeySleep1%
  }	
  Else
    Send, @huh????%v_iPosition%
  Sleep 50
}


Nice idea on using the Shift + W, gotta do whatever comes intuitve and feels right ;-) I'm already using a modifier with W,A,S,D to switch to vehicle postions, W is F1, A is F2 etc.

Ah these ideas flowing keep getting better and better. I originally started just using AutoHotkey to extend the functionality of my MX1000 mouse but more ideas keep popping up all the time.

Harmor
  • Members
  • 182 posts
  • Last active: Sep 20 2007 05:09 AM
  • Joined: 06 Nov 2005
Maybe you can help me with this script:

SpotHere()
{
   MouseGetPos, , ypos
   offsetY := 30
   ; TODO: Figure out coord system, coordinate system migrates
   ;if(ypos > 382)
   ;{
   ;   offsetY := offsetY - ypos + 382
   ;}
   sleep 20
   MouseClick, Right, , , , , D
   sleep 40
   MouseClick, Right, , , , , U
   DllCall("mouse_event", uint,1, int,20, int,offsetY, uint,0, int,0 )
;   SayToTeam("ypos ". ypos . " offsetY " . offsetY)
   sleep 40
   MouseClick, Left, , , , , D
   sleep 40
   MouseClick, Left, , , , , U
   DllCall("mouse_event", uint,1, int,-20, int,-offsetY, uint,0, int,0 )
   Sleep 200
}
;
; Spot in 20x20 square area in Commander screen
; 
$^LButton::
   DllCall("mouse_event", uint, 1, int, -10, int, -10, uint,0, int,0 )
   SpotHere()
   DllCall("mouse_event", uint, 1, int, 20, int, 0, uint,0, int,0 )
   SpotHere()
   DllCall("mouse_event", uint, 1, int, 0, int, 20, uint,0, int,0 )
   SpotHere()
   DllCall("mouse_event", uint, 1, int, -20, int, 0, uint,0, int,0 )
   SpotHere()
return

I use this script while in commander view. It will Right+click spot in a 20x20 square area just by clicking CTRL+LBUTTON.

The problem with the script is when you get near the bottom of the screen, the popup menu is no longer to the bottom right of the cursor's current position...but rather can be above the cursor.

On a 1024x768 screen the popup window is 382 pixels from the bottom. If you click below this line then the popup window is doesn't move down with the mouse. I had tried this:

   MouseGetPos, , ypos
   offsetY := 30
   if(ypos > 382)
   {
      offsetY := offsetY - ypos + 382
   }
But it doesn't work since the coordinates MouseGetPos returns migrates and drifts. I read in another thread it was due to acceleration of the mouse.

Any help would be appreciated.

This is the only thread that I found that could make a possible work around:
<!-- m -->http://www.autohotke...opic.php?t=5605<!-- m -->
//TODO: Create kewl sig...

xstream
  • Members
  • 1 posts
  • Last active: Aug 01 2006 10:33 PM
  • Joined: 01 Aug 2006
It would be helpful if people also posted their key mapping. This could help decipher your code.

Lanser
  • Members
  • 20 posts
  • Last active: Feb 01 2007 09:21 PM
  • Joined: 24 Mar 2006

It would be helpful if people also posted their key mapping. This could help decipher your code.


Well I've left the key mappings as default. Easier that way.

Harmor
  • Members
  • 182 posts
  • Last active: Sep 20 2007 05:09 AM
  • Joined: 06 Nov 2005
Quickly spot in a triangle around current position. I use the NumpadSub key (the minus key on the Number pad), because its right next to my thumb on my mouse. Nothing really special in this script, all it does is free your left hand up for a 2 seconds.

MouseEvent(a_xpos, a_ypos)
{
   DllCall("mouse_event", uint,1, int,a_xpos, int,a_ypos, uint,0, int,0 )
}

CammoRoseSpot()
{
   Send, {q Down}
   Sleep 100
   MouseClick, Left, , , , , D
   sleep 40
   MouseClick, Left, , , , , U
   Send, {q Up}
   Sleep 100
}

;
; Press NumpadSub to spot a in a triangle around current position
;
$NumpadSub::
   MouseEvent(-24, 20)
   Sleep 150
   CammoRoseSpot()
   MouseEvent(24, -40)
   Sleep 150
   CammoRoseSpot()
   MouseEvent(24, 40)
   Sleep 150
   CammoRoseSpot()
   MouseEvent(-24, -20)
   Sleep 150
return

//TODO: Create kewl sig...

Harmor
  • Members
  • 182 posts
  • Last active: Sep 20 2007 05:09 AM
  • Joined: 06 Nov 2005
Here's a little script that I use to connect to a server in my Favorites server list. What I do is hold down the Numpad 8 key and it will double click on the server in my Favorite's list and then press the OK button 2 seconds later. This way I can hold the button down to log into a server.

The "index" is from 0 to 14, 0 being the first server in the your favorite's list, and 14 being the last visible (I don't scroll down if the index is past 14).

;
; AutoHotkey      Version: 1.1.2878+
; Language:       English
; Platform:       Win9x/NT
;
;
; Only run this script when bf2.exe is running in the foreground
;
#SingleInstance force
#InstallKeybdHook 
#InstallMouseHook


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 Ctrl+V while BF2 is active
$^v::
	Sleep 200
   SetKeyDelay, 30, 30
	Send,  {Space}%clipboard%
   SetKeyDelay, 0
return
;
; Double click then press the OK button 2 seconds later on 
; Favorites server (a_index 0-14) 
;
connectToFavoritesServer(a_iIndex)
{
   if( (a_iIndex >= 0) && (a_iIndex <= 14))
   {
      ypos := 145 + 20 * a_iIndex
      MouseClick, Left, 413, ypos
      MouseClick, Left, 413, ypos
      Sleep 2000
      MouseClick, Left, 614, 404
   }

}
;
; Double click on first server in list (favorites) and 
; then press the OK button 2 seconds later while holding
; down Numpad8
;
$Numpad8::
$NumpadUp:
   Loop
   {
      if( IsKeyPressed("Numpad8") || IsKeyPressed("NumpadUp") )
      {
         connectToFavoritesServer(0)
      }
      else
      {
         break
      }
   }
return
;
; Returns 1 if %a_szKeyName% is being pressed, otherwise 0
;
IsKeyPressed(a_szKeyName)
{
   GetKeyState, state, %a_szKeyName%, P
   If state = D  ; The key is not being pressed
   {
      Return 1
   }
   Return 0
} 

//TODO: Create kewl sig...

afterU
  • Guests
  • Last active:
  • Joined: --
Hi guys, pls help me, its my first time when i try to do some macros in game. I want to know in which place i must write all my scripts? In game console or in controls notepads? :?:
And what should I make to do the script for a TV rocket (авто clickig)? help pls

Lanser
  • Members
  • 20 posts
  • Last active: Feb 01 2007 09:21 PM
  • Joined: 24 Mar 2006

I want to know in which place i must write all my scripts? In game console or in controls notepads?


Your best bet like with all things is to start with the basics and work your way up. Look at the "Tutorial and Overview" page http://www.autohotke...cs/Tutorial.htm Open a file in notepad, save it with a '.ahk' extension and run it.

Experiment with simple things first, maybe set up hotkeys to send keystrokes/letters/numbers to Notepad for instance, build up your confidence that you can get a simple script working. Once you get the basics you can start adding on and testing the more complex ideas you're interested in.

EDIT: Once you're comfortable with the basics you might consider using a another text editor rather than Notepad, you could try PSPad, Notepad++, JSEdit or many more