Need help with a BF2 script Topic is solved

Ask gaming related questions (AHK v1.1 and older)
NarK

Need help with a BF2 script

Post by NarK » 25 Dec 2015, 00:53

Hello,

I am trying to create a script which cycles through the rear view camera, flyby camera and the cockpit..
For some reason my script skips the keywait and executes what comes next.. tried it in windows explorer.. and the script is not working at all in game.... the F11 wont work in game for example..

Code: Select all

SendMode Input  ;

$RControl::rearview()

Cockpit()
{
	SendInput {F9}
	SendInput {F9}
	return
}

Rearview()
{
	SendInput {s}
	KeyWait RControl
	FlyBy()
}

FlyBy()
{
	SendInput {w}
	KeyWait RControl
	Cockpit()
}
The cockpit is F9
rearview is F11
flyby is F12 but I put in w for testing which failed :(

please help me
Shadowpheonix
Posts: 1259
Joined: 16 Apr 2015, 09:41

Re: Need help with a BF2 script  Topic is solved

Post by Shadowpheonix » 25 Dec 2015, 17:58

The way your script is written, what happens is...
1. You press RControl.
2. F11 (actually s in the test code you posted) is sent to the active window.
3. The script waits for you to release RControl.
4. F12 (w in your test code) is sent to the active window.
5. The script sees RControl is not being held, so it basically ignores the KeyWait in the FlyBy section.
6. F9 is sent twice to the active window.

Try this instead...

Code: Select all

SendMode Input  ;
 
$RControl::
Count := !Count
If Count
	SendInput {F11}
If !Count
	SendInput {F12}
KeyWait, RControl
SendInput {F9 2}
Return
This does the following...
1. You press RControl.
2. If it is an odd press (IE: press 1, 3, 5, 7, etc), then F11 is sent to the active window. F12 is sent on even presses.
3. The script waits for you to release RControl.
4. F9 is sent twice to the active window.
Post Reply

Return to “Gaming Help (v1)”