badmojo
Joined: 11 Nov 2005 Posts: 150
|
Posted: Mon Apr 28, 2008 2:22 am Post subject: Single-key toggle doesn't work in game |
|
|
i'm trying to use AHK to toggle 'walk' and 'run' mode in a game. the idea is when i press a key, it will auto-repeat itself until i press the same key to make it stop. but somehow it doesn't work even though it works on notepad, etc. can someone suggest what i need to do differently in order to get it working?
| Code: | ; "Always Run" mode
; Send shift+w continuously while 'r' key is pressed
; Press 'w' to stop
$r::
Loop
{
Send, {Shift Down}{w down}
Sleep 250
If !GetKeyState("w", "U")
{
Send, {Shift Up}
Break
}
}
Return |
the above code works fine but since i'm trying to use a single key for both actions, i'm trying this code below which i "borrowed" from here only functions with Notepad, etc but not inside the game. am i missing something?
| Code: | #MaxThreadsPerHotkey 2
$r::
PressKey := ! PressKey ;Toggle PressKey True/False
Loop
{ If ! PressKey
Break ;If PressKey is False, stop pressing key
Send +{w}
Sleep 250 ;Delay between keypresses
}
Return
#MaxThreadsPerHotkey 1 |
|
|