| View previous topic :: View next topic |
| Author |
Message |
spork
Joined: 20 Oct 2006 Posts: 33
|
Posted: Fri Oct 20, 2006 6:13 am Post subject: battlefield 2142 crouch help |
|
|
hi im trying to get battlefield 2142 crouch to work when you press the button the guy stays crouched like bf2 and now he dosent i tred many many scripts that dont work..someone please help me...this is what i got and it needs help
thanks
| Code: | c::
Send, {c down} ; Initiate 'Crouch'
If IsKeyPressed("c") ; Check if 'c' pressed. If pressed & released, Break loop.
Send, {c up} ; Release 'Crouch' |
c is my crouch button btw... |
|
| Back to top |
|
 |
holomind
Joined: 11 Mar 2006 Posts: 341 Location: Munich, Germany
|
|
| Back to top |
|
 |
spork
Joined: 20 Oct 2006 Posts: 33
|
Posted: Fri Oct 20, 2006 6:34 am Post subject: |
|
|
i was lookin at that and came up with this ..but it dosent work..
i can use the click feature becase its a button not a mouse button
c::
Send, {c down}
KeyWait, c, D ; wait here until next c (=toggle)
Send, {c up}
Return
when the key is pressed nothing happens no letter appears and in game in fact it crouches but dosent toggle.. |
|
| Back to top |
|
 |
holomind
Joined: 11 Mar 2006 Posts: 341 Location: Munich, Germany
|
Posted: Fri Oct 20, 2006 6:42 am Post subject: |
|
|
i guess your problem is, that c is sent only once. one c down.
but you maybe want to have repeated sends of c ?
| Code: |
c::
SetTimer, send_c , 20
keyWait, c , D
SetTimer, send_c, off
return
send_c:
Send, {c}
return
|
this sends repeated c keys each 20mseconds
you can also try to remap the capslock, which is normally sticky.
i dont know if this works.
|
|
| Back to top |
|
 |
spork
Joined: 20 Oct 2006 Posts: 33
|
Posted: Fri Oct 20, 2006 6:50 am Post subject: |
|
|
humm..nope htat dosent work either..
the goal im trying to accomplish is simply that the c button toggles
on and off
ie: up and down
like i push c and the button stays down so i can crouch
until i push it again so that i can come back up from crouching..
right now its one fluic motion horrible...lol |
|
| Back to top |
|
 |
holomind
Joined: 11 Mar 2006 Posts: 341 Location: Munich, Germany
|
Posted: Fri Oct 20, 2006 6:57 am Post subject: |
|
|
i dont have more ideas, perhaps you should get a little rock and put it on the key. that would be fair cheating in the game  |
|
| Back to top |
|
 |
spork
Joined: 20 Oct 2006 Posts: 33
|
Posted: Fri Oct 20, 2006 7:01 am Post subject: |
|
|
| lmao..the mean thing is..it did work at one point in fact but the space bar was messed up...i would push space and it would then toggle crouch..way messed up i dont know how that happend it was trippy..made me so mad because iwas useing the new version i reverted back becase it does not work right for me the program crashes |
|
| Back to top |
|
 |
Lanser
Joined: 24 Mar 2006 Posts: 20
|
Posted: Fri Oct 20, 2006 9:18 am Post subject: |
|
|
Hmmn not sure why it isn't working for you know, I had setup a crouch toggle method for BF2 and it still works in BF2142, initially I was using the toggle on/off method but I decided the default Crouch operation became handy in BF2 as well. So instead my method acts normal when I press and hold 'Ctrl' but if I double tap within a specified time window a loop is run to press and hold Ctrl, simply press and release Ctrl again to break out of Crouch. Maybe you could adapt it to your purposes. I've already posted this some time back in the main BF2 thread ...
| Quote: |
~LCtrl up:: ;use LCtrl "up" so it doesn't get triggered when you hold ctrl
Goto, Crouch
Crouch:
; Changed: Trigger was changed to "~LCtrl" 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, {LCtrl down} ; Initiate 'Crouch'
If IsKeyPressed("LCtrl") ; Check if 'LCtrl' pressed. If pressed & released, Break loop.
Send, {LCtrl 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 |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4710 Location: Boulder, CO
|
Posted: Fri Oct 20, 2006 3:57 pm Post subject: |
|
|
Two things to try: add $ to the hotkey name, so the hotkey won't be triggered with the sent "c", and KeyWait until the "c" key is released (not until it is pressed again). | Code: | $c::
Send {c down}
KeyWait c
Send {c up}
Return | You could also experiment with SendPlay, SendInput instead of SendEvent (Send). |
|
| Back to top |
|
 |
slomz
Joined: 03 Sep 2006 Posts: 601 Location: Iowa, U.S.
|
Posted: Fri Oct 20, 2006 8:51 pm Post subject: |
|
|
| Also laszlo, add a GetKeyState in the hotkey. No BF2 macros work without it as I have come to learn. |
|
| Back to top |
|
 |
spork
Joined: 20 Oct 2006 Posts: 33
|
Posted: Fri Oct 20, 2006 11:38 pm Post subject: |
|
|
| thanks guys ill do some testing here on all that will let ya know what i come up with.. |
|
| Back to top |
|
 |
spork
Joined: 20 Oct 2006 Posts: 33
|
Posted: Fri Oct 20, 2006 11:50 pm Post subject: |
|
|
| Code: | ~c up:: ;use c "up" so it doesn't get triggered when you hold ctrl
Goto, Crouch
Crouch:
; Changed: Trigger was changed to "~LCtrl" 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, {c down} ; Initiate 'Crouch'
If IsKeyPressed("c") ; Check if 'LCtrl' pressed. If pressed & released, Break loop.
Send, {c 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
} |
this is what i came up with works like a charm dubble tap c and u can crouch press c again and your back on ur feet praize lanser awsome ty
i only have one question how do i change it tomiddle mouse button its mbutton but im pretty sure send wont work also its gota be Click Mbutton something lol i got a diffrent function to map to that..also im maping the scroll up and down function on the mouse in game to look forward and back for anyone who wants ta know  |
|
| Back to top |
|
 |
Laszlo
Joined: 14 Feb 2005 Posts: 4710 Location: Boulder, CO
|
Posted: Sat Oct 21, 2006 3:07 am Post subject: |
|
|
This looks functionally equivalent. Does not it work? | Code: | ~c up::
If (a_tickCount-lasttime < 400) ; If c was pressed within 400ms: initiate Crouch
{
Send {c down} ; Initiate 'Crouch'
If GetKeyState("c") ; Check if c pressed
Send {c up} ; Release "Crouch'
}
lasttime:=a_tickCount
Return | If it does, you could further simplify it. |
|
| Back to top |
|
 |
holomind
Joined: 11 Mar 2006 Posts: 341 Location: Munich, Germany
|
Posted: Sat Oct 21, 2006 10:53 am Post subject: |
|
|
@lazlo: i guess the difference is that in the one example with "loop" the key is sent repeatedly, and in your example only one c-down is sent.
if you have a windows programm this might work as the key is repeated automatically. but perhaps the game does not recognize the c-down up but only checks for c-pressed ?
this means my example with settimer would also work if you change settimer ,...,20 to settimer, ...,0
but this looks like an endless-loop... (100%cpu ?!)
there is a difference in keywait and GetKeyState
a) Keywait. waits at this line in the programm until the "watched" key is pressed. like a "pause" (or sleep until key is pressed)
b) getkeystate only looks into the keybuffer if the key is pressed "now" (realtime) and returns immediately.
so they are not "functionally the same"
but using this loop thing is an endless loop and "bad" in my opinion (when there is no "sleep" in between as the cpu is constantly watching the keystate 100%cpu, which is nonsense.
my example would then look like this
| Code: | $c:: ; prevent recursion with $
SetTimer, send_c_key , 0
keyWait, c , D ; currently is D, so waits for "next" D = toggle
SetTimer, send_c_key, off
return
send_c_key:
Send, {c}
return
|
actually settimer,...,0 means settimer,...,10 on window 2k or xp
| Quote: | From SetTimer-Documentation:
Currently, timers cannot run much more often than every 10ms on Windows XP/2000/NT and about 55ms on Windows 9x. Specifying a Period less than this will usually result in an actual interval of 10 or 55 (but this policy could change in future versions so shouldn't be relied upon).
|
|
|
| Back to top |
|
 |
slomz
Joined: 03 Sep 2006 Posts: 601 Location: Iowa, U.S.
|
Posted: Sat Oct 21, 2006 2:38 pm Post subject: |
|
|
| Code: |
$c::
GetKeyState, state, C, P
if State = D
break
Send, {Alt down}
return
$c up::
GetKeyState, state, C, P
if State = U
break
Send, {Alt up}
return |
Not sure if this works. |
|
| Back to top |
|
 |
|