AutoHotkey Community

It is currently May 26th, 2012, 2:04 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 15 posts ] 
Author Message
PostPosted: July 30th, 2006, 10:02 pm 
Offline

Joined: November 6th, 2005, 5:25 am
Posts: 182
I don't know what they did, but the latest version of AutoHotkey (1.1.2878) fixed a problem where you couldn't send certain key strokes to BF2 - thanks guys.

The same technique used below could be used for grenades and M203s. The functions below don't work with the Assault Kit's Smoke Grenade.

So here is a pack of "Throw" functions.

  • ThrowClaymoreOnly() - Optimized to throw a single Claymore and then switch back to main weapon
  • ThrowMedicBag() - Throws a single Medic Bag and switches back to main weapon (doesn't work for other kits - but is fast)
  • ThrowSupplyOrMedicBagC4() - Optimized for throwing Supply Bags, but can throw Medic and a C4 as well
  • ThrowATMineOrSupplyMedicBagC4() - Optimized for throwing AT mines, but can also throw C4, Supply and Medic bags as well
  • ThrowC4() - Optimized to throw a single C4 and then switch to main weapon
  • ThrowC4andSwitchToDetinator() - Optimized to throw 1x C4 and then switch to Detinator
  • Throw2xC4andSwitchToDetinator() - Optimized to throw 2x C4 and then Switch to the Detinator
  • Throw3xC4andSwitchToDetinator() - Optimized to throw 3x C4 and then Swtich to the Detinator
  • Throw2xC4andExplode() - Optimized to throw 2x C4 and then immediately explode (you will be killed)
  • ThrowC4andExplode() - Optimized to throw 1x C4 and immediately explode (you will be killed)
  • Throw3xC4andExplode() - Optimized to throw 3x C4 and immediately explode (you will be killed)
  • ThrowAny() - This is the catch all function if you change kits often. The delays have been slowed to work with all kits - not a good idea to use with SpecOps kit though


By default I mapped these functions to press the '5' key and 'Shift + 5'; however while sprinting you need to depress the Shift key briefly. The keymap is for 'Shift+5' allows the function to run, but you must depress the Shift key briefly (I tried using {LShift Up} and BlockInput, on and stuff, but I didn't get it to work).

You'll need to goto the bottom of this script and uncomment the function you wish to use. Currently pressing '5' or 'Shift+5' does nothing until you uncomment (remove the ';') in the script below:

Code:
;
; 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

;
; Disable the Window's keys so they don't switch to desktop while in-game
;
$LWin::   ; Left Windows Button
$RWin::   ; Right Windows Button
   ; Do nothing
return

$^CapsLock::
   ExitApp
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Pressing Ctrl+V while BF2 is active
;
$^v::
   Sleep 200
   SetKeyDelay, 40
   Send,  {Space}%clipboard%
   SetKeyDelay, 0
return

ThrowClaymoreOnly()
{
   Send, {5 down}
   Sleep 60
   Send, {5 up}
   Sleep 950
   MouseClick, Left, , , , , D
   sleep 100
   MouseClick, Left, , , , , U
   Send, {3 down}
   Sleep 40
   Send, {3 up}
}

ThrowMedicBag()
{
   Send, {5 down}
   Sleep 60
   Send, {5 up}
   Sleep 100
   MouseClick, Left, , , , , D
   sleep 400
   MouseClick, Left, , , , , U
   Send, {3 down}
   Sleep 40
   Send, {3 up}
}

ThrowSupplyOrMedicBagC4()
{
   Send, {5 down}
   Sleep 60
   Send, {5 up}
   Sleep 600
   MouseClick, Left, , , , , D
   sleep 400
   MouseClick, Left, , , , , U
   Send, {3 down}
   Sleep 40
   Send, {3 up}
}

ThrowATMineOrSupplyMedicBagC4()
{
   Send, {5 down}
   Sleep 60
   Send, {5 up}
   Sleep 999
   MouseClick, Left, , , , , D
   sleep 500
   MouseClick, Left, , , , , U
   Send, {3 down}
   Sleep 40
   Send, {3 up}
}

ThrowC4()
{
   Send, {5 down}
   Sleep 60
   Send, {5 up}
   Sleep 400
   MouseClick, Left, , , , , D
   sleep 100
   MouseClick, Left, , , , , U
   Send, {3 down}
   Sleep 40
   Send, {3 up}
}

ThrowC4andSwitchToDetinator()
{
   Send, {5 down}
   Sleep 60
   Send, {5 up}
   Sleep 500
   MouseClick, Left, , , , , D
   sleep 100
   MouseClick, Left, , , , , U
   Sleep 700
   MouseClick, right, , , , , D
   sleep 100
   MouseClick, right, , , , , U
}

Throw2xC4andSwitchToDetinator()
{
   Send, {5 down}
   Sleep 60
   Send, {5 up}
   Sleep 500
   MouseClick, Left, , , , , D
   sleep 100
   MouseClick, Left, , , , , U
   Sleep 700
   MouseClick, Left, , , , , D
   sleep 100
   MouseClick, Left, , , , , U
   sleep 700
   MouseClick, right, , , , , D
   sleep 100
   MouseClick, right, , , , , U
}

Throw3xC4andSwitchToDetinator()
{
   Send, {5 down}
   Sleep 60
   Send, {5 up}
   Sleep 500
   MouseClick, Left, , , , , D
   sleep 100
   MouseClick, Left, , , , , U
   Sleep 700
   MouseClick, Left, , , , , D
   sleep 100
   MouseClick, Left, , , , , U
   Sleep 700
   MouseClick, Left, , , , , D
   sleep 100
   MouseClick, Left, , , , , U
   sleep 700
   MouseClick, right, , , , , D
   sleep 100
   MouseClick, right, , , , , U
}

Throw2xC4andExplode()
{
   Send, {5 down}
   Sleep 60
   Send, {5 up}
   Sleep 500
   MouseClick, Left, , , , , D
   sleep 100
   MouseClick, Left, , , , , U
   Sleep 700
   MouseClick, Left, , , , , D
   sleep 100
   MouseClick, Left, , , , , U
   sleep 700
   MouseClick, right, , , , , D
   sleep 100
   MouseClick, right, , , , , U
   Sleep 200
   MouseClick, left, , , , , D
   sleep 100
   MouseClick, left, , , , , U
}

ThrowC4andExplode()
{
   Send, {5 down}
   Sleep 60
   Send, {5 up}
   Sleep 500
   MouseClick, Left, , , , , D
   sleep 100
   MouseClick, Left, , , , , U
   Sleep 700
   MouseClick, right, , , , , D
   sleep 100
   MouseClick, right, , , , , U
   Sleep 200
   MouseClick, left, , , , , D
   sleep 100
   MouseClick, left, , , , , U
}

Throw3xC4andExplode()
{
   Send, {5 down}
   Sleep 60
   Send, {5 up}
   Sleep 500
   MouseClick, Left, , , , , D
   sleep 100
   MouseClick, Left, , , , , U
   Sleep 700
   MouseClick, Left, , , , , D
   sleep 100
   MouseClick, Left, , , , , U
   Sleep 700
   MouseClick, Left, , , , , D
   sleep 100
   MouseClick, Left, , , , , U
   sleep 700
   MouseClick, right, , , , , D
   sleep 100
   MouseClick, right, , , , , U
   Sleep 200
   MouseClick, left, , , , , D
   sleep 100
   MouseClick, left, , , , , U
}

ThrowAny() ; Slow
{
   Send, {5 down}
   Sleep 60
   Send, {5 up}
   Sleep 1000
   MouseClick, Left, , , , , D
   sleep 500
   MouseClick, Left, , , , , U
   Send, {3 down}
   Sleep 40
   Send, {3 up}
}

;
; Remove Comment ';' to do that function
;
$5::
$+5:: ; Shift + 5 (must depress Shift briefly - can't use kit while sprinting)

;ThrowClaymoreOnly()
;ThrowMedicBag()
;ThrowSupplyOrMedicBagC4()
;ThrowATMineOrSupplyMedicBagC4()
;ThrowC4()
;ThrowC4andSwitchToDetinator()
;Throw2xC4andSwitchToDetinator()
;Throw3xC4andSwitchToDetinator()
;Throw2xC4andExplode()
;ThrowC4andExplode()
;Throw3xC4andExplode()
;ThrowAny() ; Slow

return

_________________
//TODO: Create kewl sig...


Report this post
Top
 Profile  
Reply with quote  
PostPosted: August 1st, 2006, 1:19 am 
Hey dude do i paste this entire scripts or what i cant get it to work i need help can u help me out to get it to work?


Report this post
Top
  
Reply with quote  
PostPosted: August 1st, 2006, 1:53 am 
Offline

Joined: November 6th, 2005, 5:25 am
Posts: 182
help wrote:
Hey dude do i paste this entire scripts or what i cant get it to work i need help can u help me out to get it to work?


Just goto the bottom of the script and remove the ';' at the front of one of the functions you want mapped when you press '5' on the keyboard.

Make sure you have the latest version of AutoHotkey or else it won't work.

_________________
//TODO: Create kewl sig...


Report this post
Top
 Profile  
Reply with quote  
PostPosted: August 1st, 2006, 1:57 am 
where do u get the latest version of autohotkey??


Report this post
Top
  
Reply with quote  
PostPosted: August 1st, 2006, 2:03 am 
so do i still ppaste the entire script and then only take out the ; before the one i want and then in game all i need to do is hit 5 and itll throw it for me and also could i do that to everything or only one?


Report this post
Top
  
Reply with quote  
PostPosted: August 1st, 2006, 3:08 am 
do i paste the entire scrips in it tho or what then i only take out the ; on the one i want or could i do it to multiple of ones and what is the latest version and what will the keys be to make it work????


Report this post
Top
  
Reply with quote  
PostPosted: August 1st, 2006, 6:06 am 
Offline

Joined: July 27th, 2006, 2:34 pm
Posts: 26
holby wrote:
do i paste the entire scrips in it tho or what then i only take out the ; on the one i want or could i do it to multiple of ones and what is the latest version and what will the keys be to make it work????


It is fairly complicated....

"You'll need to goto the bottom of this script (which means the entire script) and uncomment the function you wish to use (which means the ONE function you want the script to perform). Currently pressing '5' (explains which key to press) or 'Shift+5' does nothing until you uncomment (remove the ';' (again explaining what to remove in case you STILL didn't understand)) in the script below:"

Is that a better explaination? Do you need step-by-step? Is English your native language?


Report this post
Top
 Profile  
Reply with quote  
PostPosted: August 1st, 2006, 6:43 am 
yes thats good thanx dude for all your help ill test it out tomorrow and let u know if it worked


Report this post
Top
  
Reply with quote  
 Post subject: lol
PostPosted: August 13th, 2006, 7:52 pm 
so w/ said code, since 5 is already mapped, what is the syntax to change it to say.. G....


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 15th, 2006, 4:31 pm 
I tried to do the Shift+5 thing, but the throw only works about 20% of the time.

I combine the shift+5 with the jump, and it only throw the C4 Sometimes. What is the correct way to use the function?

and how do you change the hotkey to something else?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 15th, 2006, 7:55 pm 
Offline

Joined: November 6th, 2005, 5:25 am
Posts: 182
Just change the line:

$5::

to something else.

like $H:: or whatever you want the hotkey to be.

Someone in another section of the forum said that the C4 function isn't working as well.

There definiately something wrong with the timing. I'll try to figure it out, but I'm really busy at the moment and probably won't get to it any time soon.

The only function above that I use regularly is Claymore one because I play sniper alot. I can't necessarily vouch for the others since I only tested them briefly until I got it to work, guess my testing didn't catch all the bugs.

_________________
//TODO: Create kewl sig...


Report this post
Top
 Profile  
Reply with quote  
PostPosted: August 15th, 2006, 8:07 pm 
Offline
User avatar

Joined: August 11th, 2004, 1:47 am
Posts: 5347
Location: UK
Harmor wrote:
I don't know what they did, but the latest version of AutoHotkey (1.1.2878) fixed a problem where you couldn't send certain key strokes to BF2 - thanks guys.
The latest version is 1.0.44.09 :?

_________________
GitHubScriptsIronAHK Contact by email not private message.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 16th, 2006, 3:08 am 
Harmor wrote:
Just change the line:

$5::

to something else.

like $H:: or whatever you want the hotkey to be.

Someone in another section of the forum said that the C4 function isn't working as well.

There definiately something wrong with the timing. I'll try to figure it out, but I'm really busy at the moment and probably won't get to it any time soon.

The only function above that I use regularly is Claymore one because I play sniper alot. I can't necessarily vouch for the others since I only tested them briefly until I got it to work, guess my testing didn't catch all the bugs.


same thing with the SHift Combo?


Report this post
Top
  
Reply with quote  
PostPosted: December 20th, 2007, 6:29 pm 
if i want the medic bag throw button to be the mouse side button what do i have to change then?


Report this post
Top
  
Reply with quote  
 Post subject: Can it do this ?
PostPosted: January 3rd, 2008, 10:55 pm 
i used the above multi script for throwing a medi kit.

i was looking for somthing to when pressed) would select medic pack, throw a pack, then reselect main weapon.

using the script it does not select the medic pack.

however when you manually select the mecic pack, and execute the macro, it throws the pack, and reselects the main weapon..

is it not designed to select the medic pack in the first place ???

any help is appreciated.

;
; 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

;
; Disable the Window's keys so they don't switch to desktop while in-game
;
$LWin:: ; Left Windows Button
$RWin:: ; Right Windows Button
; Do nothing
return

$^CapsLock::
ExitApp
return
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Pressing Ctrl+V while BF2 is active
;
$^v::
Sleep 200
SetKeyDelay, 40
Send, {Space}%clipboard%
SetKeyDelay, 0
return

ThrowClaymoreOnly()
{
Send, {5 down}
Sleep 60
Send, {5 up}
Sleep 950
MouseClick, Left, , , , , D
sleep 100
MouseClick, Left, , , , , U
Send, {3 down}
Sleep 40
Send, {3 up}
}

ThrowMedicBag()
{
Send, {5 down}
Sleep 60
Send, {5 up}
Sleep 100
MouseClick, Left, , , , , D
sleep 400
MouseClick, Left, , , , , U
Send, {3 down}
Sleep 40
Send, {3 up}
}

ThrowSupplyOrMedicBagC4()
{
Send, {5 down}
Sleep 60
Send, {5 up}
Sleep 600
MouseClick, Left, , , , , D
sleep 400
MouseClick, Left, , , , , U
Send, {3 down}
Sleep 40
Send, {3 up}
}

ThrowATMineOrSupplyMedicBagC4()
{
Send, {5 down}
Sleep 60
Send, {5 up}
Sleep 999
MouseClick, Left, , , , , D
sleep 500
MouseClick, Left, , , , , U
Send, {3 down}
Sleep 40
Send, {3 up}
}

ThrowC4()
{
Send, {5 down}
Sleep 60
Send, {5 up}
Sleep 400
MouseClick, Left, , , , , D
sleep 100
MouseClick, Left, , , , , U
Send, {3 down}
Sleep 40
Send, {3 up}
}

ThrowC4andSwitchToDetinator()
{
Send, {5 down}
Sleep 60
Send, {5 up}
Sleep 500
MouseClick, Left, , , , , D
sleep 100
MouseClick, Left, , , , , U
Sleep 700
MouseClick, right, , , , , D
sleep 100
MouseClick, right, , , , , U
}

Throw2xC4andSwitchToDetinator()
{
Send, {5 down}
Sleep 60
Send, {5 up}
Sleep 500
MouseClick, Left, , , , , D
sleep 100
MouseClick, Left, , , , , U
Sleep 700
MouseClick, Left, , , , , D
sleep 100
MouseClick, Left, , , , , U
sleep 700
MouseClick, right, , , , , D
sleep 100
MouseClick, right, , , , , U
}

Throw3xC4andSwitchToDetinator()
{
Send, {5 down}
Sleep 60
Send, {5 up}
Sleep 500
MouseClick, Left, , , , , D
sleep 100
MouseClick, Left, , , , , U
Sleep 700
MouseClick, Left, , , , , D
sleep 100
MouseClick, Left, , , , , U
Sleep 700
MouseClick, Left, , , , , D
sleep 100
MouseClick, Left, , , , , U
sleep 700
MouseClick, right, , , , , D
sleep 100
MouseClick, right, , , , , U
}

Throw2xC4andExplode()
{
Send, {5 down}
Sleep 60
Send, {5 up}
Sleep 500
MouseClick, Left, , , , , D
sleep 100
MouseClick, Left, , , , , U
Sleep 700
MouseClick, Left, , , , , D
sleep 100
MouseClick, Left, , , , , U
sleep 700
MouseClick, right, , , , , D
sleep 100
MouseClick, right, , , , , U
Sleep 200
MouseClick, left, , , , , D
sleep 100
MouseClick, left, , , , , U
}

ThrowC4andExplode()
{
Send, {5 down}
Sleep 60
Send, {5 up}
Sleep 500
MouseClick, Left, , , , , D
sleep 100
MouseClick, Left, , , , , U
Sleep 700
MouseClick, right, , , , , D
sleep 100
MouseClick, right, , , , , U
Sleep 200
MouseClick, left, , , , , D
sleep 100
MouseClick, left, , , , , U
}

Throw3xC4andExplode()
{
Send, {5 down}
Sleep 60
Send, {5 up}
Sleep 500
MouseClick, Left, , , , , D
sleep 100
MouseClick, Left, , , , , U
Sleep 700
MouseClick, Left, , , , , D
sleep 100
MouseClick, Left, , , , , U
Sleep 700
MouseClick, Left, , , , , D
sleep 100
MouseClick, Left, , , , , U
sleep 700
MouseClick, right, , , , , D
sleep 100
MouseClick, right, , , , , U
Sleep 200
MouseClick, left, , , , , D
sleep 100
MouseClick, left, , , , , U
}

ThrowAny() ; Slow
{
Send, {5 down}
Sleep 60
Send, {5 up}
Sleep 1000
MouseClick, Left, , , , , D
sleep 500
MouseClick, Left, , , , , U
Send, {3 down}
Sleep 40
Send, {3 up}
}

;
; Remove Comment ';' to do that function
;
$5::
$+5:: ; Shift + 5 (must depress Shift briefly - can't use kit while sprinting)

;ThrowClaymoreOnly()
ThrowMedicBag()
;ThrowSupplyOrMedicBagC4()
;ThrowATMineOrSupplyMedicBagC4()
;ThrowC4()
;ThrowC4andSwitchToDetinator()
;Throw2xC4andSwitchToDetinator()
;Throw3xC4andSwitchToDetinator()
;Throw2xC4andExplode()
;ThrowC4andExplode()
;Throw3xC4andExplode()
;ThrowAny() ; Slow

return


Report this post
Top
  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Exabot [Bot], JamixZol, Stigg and 20 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group