| View previous topic :: View next topic |
| Author |
Message |
Acindo Guest
|
Posted: Sun Feb 07, 2010 9:57 am Post subject: Toggle Crouch and Sprint for Bad Company 2 |
|
|
Hey all,
It took me a while to find something that works, I now have toggle crouch and sprint but was wondering if it could be improved. I have NO idea how to script and just used what other people had.
It works perfectly, I just dont like having 1 key to start the script and the action to be a different key.
This is what ive got:
~*LShift::
GetKeyState, state, LCtrl
if state = U
Send {LCtrl Down}
else
Send {LCtrl Up}
return
~*XButton1::
GetKeyState, state, P
if state = U
Send {P Down}
else
Send {P Up}
return
But I only want to have LShift and XButton1 in there, I dont like how Shift starts the Control toggle and XButton1 starts the P toggle..
Thanks for any assistance, and even if nothing works this will do me fine  |
|
| Back to top |
|
 |
Acindo
Joined: 07 Feb 2010 Posts: 3 Location: Sydney, Australia
|
Posted: Mon Feb 08, 2010 9:01 am Post subject: |
|
|
| Anyone have any suggestions? |
|
| Back to top |
|
 |
aaffe
Joined: 17 May 2007 Posts: 1002 Location: Germany - Deutschland
|
Posted: Mon Feb 08, 2010 2:16 pm Post subject: |
|
|
Like this?:
| Code: | ~*LShift::
GetKeyState, state, Lshift
if state = P
Send {LCtrl Down}
else
Send {LCtrl Up}
return
~*XButton1::
GetKeyState, state, XButton1
if state = P
Send {P Down}
else
Send {P Up}
return |
|
|
| Back to top |
|
 |
Acindo
Joined: 07 Feb 2010 Posts: 3 Location: Sydney, Australia
|
Posted: Tue Feb 09, 2010 2:45 am Post subject: |
|
|
Hey thanks for replying.
I think I might not of explained myself very well.
What I want to be able to do is press LShift to toggle LShift down then press it again to toggle it up, same for the XButton1.
I would like to be able to remove LCtrl and P from the script if its possible, but no other toggle script I tried seemed to work. |
|
| Back to top |
|
 |
aaffe
Joined: 17 May 2007 Posts: 1002 Location: Germany - Deutschland
|
Posted: Tue Feb 09, 2010 7:32 am Post subject: |
|
|
Then try to adapt this script to your keys:
| Code: | #MaxThreadsPerHotkey 2 ; Need this to allow two key press threads to run at same time
MButton::
Toggle:=!Toggle
While (Toggle)
{
Send {w down}
Sleep -1 ;Gibt dem Script die Chance, auf Nachrichten zu reagieren
}
Send {w up}
Return |
|
|
| Back to top |
|
 |
lonepie
Joined: 24 Feb 2010 Posts: 1
|
Posted: Wed Feb 24, 2010 1:54 am Post subject: |
|
|
just stumbled up on this thread, here's my attempt:
| Code: |
crouchState:=0
~c::Goto Crouch
~Space::
if crouchState
GoSub, Crouch
return
~w & LShift Up::
if crouchState
GoSub, Crouch
Send {LShift down}
while GetKeyState("w","P") and not GetKeyState("LShift", "P")
{
if crouchState
break
sleep 100 ; prevents high cpu usage
}
if GetKeyState("LShift")
Send {LShift up}
;SoundBeep
sleep 125
return
Crouch:
if crouchState
Send {LCtrl up}
else
Send {LCtrl down}
crouchState := !crouchState
return
|
http://bunchafunk.googlecode.com/files/crouch_toggle.ahk |
|
| Back to top |
|
 |
Zaephon
Joined: 03 Mar 2010 Posts: 1
|
Posted: Wed Mar 03, 2010 2:11 pm Post subject: |
|
|
Hi guys.
Your attempt is good, but for me the only thing which is missing is the ability of going ro crouch while sprinting, I've tryed few things but still doesn't work.
Someone can help me ?
Thanks. |
|
| Back to top |
|
 |
Abigor Guest
|
Posted: Fri Mar 05, 2010 12:21 am Post subject: This works for l-shift |
|
|
Try something like this, if you tap L - shift 2 times it will toggle it on where it is held down you can hit L- Shift again to turn if off. You can edit this to be another key if you want.
#UseHook
#NoEnv ;
SendMode Input
SetWorkingDir %A_ScriptDir%
~LShift up:: ;use LShift "up" so it doesn't get triggered when you hold LShift
Goto, Sprint
Sprint:
; Changed: Trigger was changed to "~LShift" 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, {LShift down} ; Initiate 'Crouch'
If IsKeyPressed("LShift") ; Check if 'LShift' pressed. If pressed & released, Break loop.
Send, {LShift 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
} |
|
| Back to top |
|
 |
|