Page 2 of 3

Re: Working Crouch Toggle Script

Posted: 2013-08-05 09:19
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.

Re: Working Crouch Toggle Script

Posted: 2013-08-05 09:25
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.

Re: Working Crouch Toggle Script

Posted: 2013-08-05 09:58
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.

Re: Working Crouch Toggle Script

Posted: 2013-08-05 14:02
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
}

Re: Working Crouch Toggle Script

Posted: 2013-08-05 17:29
by a3dboy1
Pachira, have you changed in-game controls as well so RCtrl is crouch in game?

Re: Working Crouch Toggle Script

Posted: 2013-08-05 19:08
by Pachira
a3dboy1 wrote:Pachira, have you changed in-game controls as well so RCtrl is crouch in game?
Yes, would that conflict?

Re: Working Crouch Toggle Script

Posted: 2013-08-05 19:18
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...

Re: Working Crouch Toggle Script

Posted: 2013-08-05 19:22
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)

Re: Working Crouch Toggle Script

Posted: 2013-08-05 19:32
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.

Re: Working Crouch Toggle Script

Posted: 2013-08-05 20:33
by smgunsftw
If all else fails, change the Crouch key back to the default LCtrl key.

Re: Working Crouch Toggle Script

Posted: 2013-08-06 17:00
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.

Re: Working Crouch Toggle Script

Posted: 2013-08-07 02:25
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?

Re: Working Crouch Toggle Script

Posted: 2013-08-07 15:37
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

Re: Working Crouch Toggle Script

Posted: 2013-08-07 20:14
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

Re: Working Crouch Toggle Script

Posted: 2013-08-12 09:50
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! :)

Re: Working Crouch Toggle Script

Posted: 2013-08-12 18:31
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.

Re: Working Crouch Toggle Script

Posted: 2013-08-12 19:07
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.

Re: Working Crouch Toggle Script

Posted: 2013-08-12 19:37
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.

Re: Working Crouch Toggle Script

Posted: 2013-08-12 22:26
by Mora
Thats brilliant. I hope it gets integrated in the pr launcher.

Re: Working Crouch Toggle Script

Posted: 2013-08-21 17:43
by Westr7
The questions are: does it work in 1.0?
Does punkbuster go nuts?
Do admins allow it?

Thanks.