Working Crouch Toggle Script

General discussion of the Project Reality: BF2 modification.
Pachira
Posts: 6
Joined: 2013-08-05 09:18

Re: Working Crouch Toggle Script

Post by Pachira »

Are the devs okay with this? I don't want to get in trouble for having this, but I would love to have this.
Spook
Posts: 2458
Joined: 2011-07-12 14:08

Re: Working Crouch Toggle Script

Post by Spook »

You are not modifying the game, why would they mind or care about it?

Btw PB has no problems with autohotkey. I am using this https://www.realitymod.com/forum/f27-pr ... ution.html with AHK for several months already and never experienced any problems with PB.
Image
Pachira
Posts: 6
Joined: 2013-08-05 09:18

Re: Working Crouch Toggle Script

Post by Pachira »

Spook wrote:You are not modifying the game, why would they mind or care about it?
Yeah I know, I just like to be careful.
Pachira
Posts: 6
Joined: 2013-08-05 09:18

Re: Working Crouch Toggle Script

Post by Pachira »

Doesn't seem to work, here is what I've got for the script:
~RCtrl up:: ;use RCtrl "up" so it doesn't get triggered when you hold ctrl
Goto, Crouch

Crouch:
; Changed: Trigger was changed to "~RCtrl" 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, {RCtrl down} ; Initiate 'Crouch'
If IsKeyPressed("RCtrl") ; Check if 'RCtrl' pressed. If pressed & released, Break loop.
Send, {RCtrl 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
}
a3dboy1
Posts: 194
Joined: 2012-09-17 17:40

Re: Working Crouch Toggle Script

Post by a3dboy1 »

Pachira, have you changed in-game controls as well so RCtrl is crouch in game?
[img]http://www.image-share.com/upload/2230/9.jpg[/img]
Pachira
Posts: 6
Joined: 2013-08-05 09:18

Re: Working Crouch Toggle Script

Post by Pachira »

a3dboy1 wrote:Pachira, have you changed in-game controls as well so RCtrl is crouch in game?
Yes, would that conflict?
a3dboy1
Posts: 194
Joined: 2012-09-17 17:40

Re: Working Crouch Toggle Script

Post by a3dboy1 »

Pachira wrote:Yes, would that conflict?
Actually, this is what you are supposed to do.
AutoHotKey has nothing to do with the game. It simply simulates pressed key when you actually don't hold it.

E.g. If you change the key to "C" you will notice that by double typing it you actually type "C" x3 times in chat/MS Word etc.

Strange, the script must work...

1. Do you have autohotkey installed?
2. Do you launch it before the game?
3. Do you have H icon in your system tray after you launch the script?
4. Try changing the key to letter or space bar and try the script in Word for example...
[img]http://www.image-share.com/upload/2230/9.jpg[/img]
Pachira
Posts: 6
Joined: 2013-08-05 09:18

Re: Working Crouch Toggle Script

Post by Pachira »

a3dboy1 wrote:Actually, this is what you are supposed to do.
AutoHotKey has nothing to do with the game. It simply simulates pressed key when you actually don't hold it.

E.g. If you change the key to "C" you will notice that by double typing it you actually type "C" x3 times in chat/MS Word etc.

Strange, the script must work...

1. Do you have autohotkey installed?
2. Do you launch it before the game?
3. Do you have H icon in your system tray after you launch the script?
4. Try changing the key to letter or space bar and try the script in Word for example...
Yes
Yes
Yes
Tested it and it seems to still be a bit naffed. I got this when I tried it with a
"aAaaaaAaaaaaaaaaaaaaaAaaaAaaAaaAaaaaaaaaaaa"

The caps ones are the ones that were put in by the autohotkey (five second intervals between I pressed each time)
a3dboy1
Posts: 194
Joined: 2012-09-17 17:40

Re: Working Crouch Toggle Script

Post by a3dboy1 »

Pachira wrote:Yes
Yes
Yes
Tested it and it seems to still be a bit naffed. I got this when I tried it with a
"aAaaaaAaaaaaaaaaaaaaaAaaaAaaAaaAaaaaaaaaaaa"

The caps ones are the ones that were put in by the autohotkey (five second intervals between I pressed each time)
The idea was to check if script works correctly and according to what I see it does. Difference in small/big cases might come from Control Panel/Keyboard/Character repeat settings. But don't bother yourself with it.

Simply, try local server with current script and see if Toggle Crouch works.
[img]http://www.image-share.com/upload/2230/9.jpg[/img]
smgunsftw
Posts: 242
Joined: 2012-10-26 21:43

Re: Working Crouch Toggle Script

Post by smgunsftw »

If all else fails, change the Crouch key back to the default LCtrl key.
Mora
Posts: 2933
Joined: 2007-08-21 12:37

Re: Working Crouch Toggle Script

Post by Mora »

I also have a script that some of you might find interesting. Its a script that automates switching FLIR on/off Its in my signature.
smgunsftw
Posts: 242
Joined: 2012-10-26 21:43

Re: Working Crouch Toggle Script

Post by smgunsftw »

Mora wrote:I also have a script that some of you might find interesting. Its a script that automates switching FLIR on/off Its in my signature.
How does it work?
Mora
Posts: 2933
Joined: 2007-08-21 12:37

Re: Working Crouch Toggle Script

Post by Mora »

smgunsftw wrote:How does it work?

Code: Select all

;RWin (right Windows key) is the button to turn on/off the script.
;LShift (left shift button) is the button to activate the script.
;If you want to remap the buttons, look up the keys in KeyList.html and change them accordingly in here.

$RWin::Suspend
$LShift::
{
Send {t down}
Send {LButton down}
Sleep 300
Send {LButton up}
Send {t up}
}

return
smgunsftw
Posts: 242
Joined: 2012-10-26 21:43

Re: Working Crouch Toggle Script

Post by smgunsftw »

Mora wrote:

Code: Select all

;RWin (right Windows key) is the button to turn on/off the script.
;LShift (left shift button) is the button to activate the script.
;If you want to remap the buttons, look up the keys in KeyList.html and change them accordingly in here.

$RWin::Suspend
$LShift::
{
Send {t down}
Send {LButton down}
Sleep 300
Send {LButton up}
Send {t up}
}

return
Thanks, no more firing a 120 HEAT shell just because you wanted to switch to thermal :D
PoisonBill
Posts: 682
Joined: 2010-10-11 14:25

Re: Working Crouch Toggle Script

Post by PoisonBill »

This thing sure screws around with you when you have it on browsing the web! :D

Works like a charm in game though, very nice! :)
Image
smgunsftw
Posts: 242
Joined: 2012-10-26 21:43

Re: Working Crouch Toggle Script

Post by smgunsftw »

PoisonBill wrote:This thing sure screws around with you when you have it on browsing the web! :D

Works like a charm in game though, very nice! :)
The only way to disable it while browsing the web is by exiting autohotkey all together, I haven't found another solution atm.
Mora
Posts: 2933
Joined: 2007-08-21 12:37

Re: Working Crouch Toggle Script

Post by Mora »

smgunsftw wrote:The only way to disable it while browsing the web is by exiting autohotkey all together, I haven't found another solution atm.
You can toggle suspend the script with $key::Suspend Just look at my script a couple of post above here.
User avatar
Mats391
PR:BF2 Lead Developer
Posts: 7643
Joined: 2010-08-06 18:06

Re: Working Crouch Toggle Script

Post by Mats391 »

smgunsftw wrote:The only way to disable it while browsing the web is by exiting autohotkey all together, I haven't found another solution atm.
i made some crouch toggle scripts a while back for some friends and myself:
this is only active while PR window is selected and you automatically uncrouch when you start chatting/using console, sprint, jump, prone or enter a vehicle (pressing E). Also it does not toggle if you hold crouch, only when you press it once.
CrouchToggle QWERTY

Code: Select all

Suspend, on
SetTitleMatchMode 2
SetTimer, KeepRunning, 500
return

KeepRunning:
WinWaitActive, BF2, ,
	if ErrorLevel = 0
	{
		Suspend, off
	}

WinWaitNotActive, BF2, ,
	if ErrorLevel = 0
	{
		SendInput {LCTrl up}
		toggle = 0
		Suspend, on
	}
return
~*F12::
	Suspend
	SendInput {LCtrl up}
	toggle = 0
Return



*$Lcontrol::    
           start_time := A_TickCount
           SendInput {LCtrl down}

           KeyWait LCtrl
           elapsed_time := A_TickCount - start_time
                if elapsed_time < 300
                { 
                    if toggle = 1
                    {
                         SendInput {LCtrl up}
                         toggle = 0
                    }
                    else
                    {
                         toggle = 1
                    }
                }
                else
                    SendInput {LCtrl Up}
Return
                    
~*z::
~*`::
~*e::
~*Space::
  SendInput {LControl Up}
  toggle = 0
Return

~*j::
~*k::
~*l:: 
	if GetKeyState("Lcontrol","L")
	{
	   Z = 1
           KeyWait LControl
           SendInput {LControl Up}        
	}
Return

~*Esc::	
	if z = 1
	{
	   Sleep 200
	   SendInput {LControl Down}
	   z = 0
           toggle = 1
	}
	else{
	   SendInput {LControl Up}
           toggle = 0
	}
Return

~*Enter:: 
~*NumpadEnter::
        if z = 1
	{
	   SendInput {LControl down}
	   z = 0
           toggle = 1
	}
Return

*LShift::	
           SendInput {LControl Up}
           toggle = 0
	   SendInput {Lshift up}   

           Sleep 30

           SendInput {LShift Down}
	   KeyWait Lshift 
           SendInput {LShift Up} 
Return
AHK QWERTY
EXE QWERTY
AHK QWERTZ
EXE QWERTZ

and since i started using C for crouch i made this:
CrouchToggle C QWERTZ:

Code: Select all

Suspend, on
SetTitleMatchMode 2
SetTimer, KeepRunning, 500
chatting = 0
return

KeepRunning:
WinWaitActive, BF2, ,
	if ErrorLevel = 0
	{
		Suspend, off
	}

WinWaitNotActive, BF2, ,
	if ErrorLevel = 0
	{
		SendInput {RShift up}
		toggle = 0
		Suspend, on
	}
return


*~$C::    
		if(chatting = 1)
			Return
			
		SendInput {RShift down}

		KeyWait C
			if toggle = 1
			{
				 SendInput {RShift up}
				 toggle = 0
			}
			else
			{
				 toggle = 1
			}
Return
                    
~*y::
~*^::
~*e::
~*Space::
  SendInput {RShift Up}
  toggle = 0
Return

~*j::
~*k::
~l:: 
	chatting = 1
	if toggle = 1
	{
		SendInput {RShift Up} 
		crouchBefore = 1   
		toggle = 0
	}
Return

~*Esc::	
	chatting = 0
	if crouchBefore = 1
	{
	   Sleep 200
	   SendInput {RShift Down}
	   crouchBefore = 0
	   toggle = 1
	}
	else{
	   SendInput {RShift Up}
	   toggle = 0
	}
Return

~*Enter:: 
~*NumpadEnter::
	chatting = 0
    if crouchBefore = 1
	{
	   SendInput {RShift down}
	   crouchBefore = 0
       toggle = 1
	}
Return

*LShift::	
	SendInput {RShift Up}
	toggle = 0
	SendInput {Lshift up}   

	Sleep 30

	SendInput {LShift Down}
	KeyWait Lshift 
	SendInput {LShift Up} 
Return
AHK CrouchToggle C
EXE CrouchToggle C
i only have a QWERTZ version for this but should be easy to change it to QWERTY on your own. You have to set right shift as crouch key in PR, this is a work around as otherwise it kept writing one "C" every time i started chatting.
Image

Mineral: TIL that Wire-guided missiles actually use wire
Mora
Posts: 2933
Joined: 2007-08-21 12:37

Re: Working Crouch Toggle Script

Post by Mora »

Thats brilliant. I hope it gets integrated in the pr launcher.
Westr7
Posts: 5
Joined: 2013-08-20 03:23

Re: Working Crouch Toggle Script

Post by Westr7 »

The questions are: does it work in 1.0?
Does punkbuster go nuts?
Do admins allow it?

Thanks.
Post Reply

Return to “PR:BF2 General Discussion”