 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Guest
|
Posted: Sat Feb 20, 2010 3:41 am Post subject: Stop autorepeating key |
|
|
Hello, can anyone help me on this, please.
The next example is a joystick sending to keys script. How can I stop the pressing key continuously and press just once.
| Code: | #Persistent ; Keep this script running until the user explicitly exits it.
SetTimer, WatchAxis, 5
return
WatchAxis:
GetKeyState, JoyX, JoyX ; Get position of X axis.
GetKeyState, JoyY, JoyY ; Get position of Y axis.
KeyToHoldDownPrev = %KeyToHoldDown% ; Prev now holds the key that was down before (if any).
if JoyX > 70
KeyToHoldDown = Right
else if JoyX < 30
KeyToHoldDown = Left
else if JoyY > 70
KeyToHoldDown = Down
else if JoyY < 30
KeyToHoldDown = Up
else
KeyToHoldDown =
if KeyToHoldDown = %KeyToHoldDownPrev% ; The correct key is already down (or no key is needed).
return ; Do nothing.
; Otherwise, release the previous key and press down the new key:
SetKeyDelay -1 ; Avoid delays between keystrokes.
if KeyToHoldDownPrev ; There is a previous key to release.
Send, {%KeyToHoldDownPrev% up} ; Release it.
if KeyToHoldDown ; There is a key to press down.
Send, {%KeyToHoldDown% down} ; Press it down.
return |
Thanks. |
|
| Back to top |
|
 |
randallf
Joined: 06 Jul 2009 Posts: 678
|
Posted: Sat Feb 20, 2010 3:44 am Post subject: |
|
|
| Which key? |
|
| Back to top |
|
 |
Guest
|
Posted: Sat Feb 20, 2010 3:47 am Post subject: |
|
|
If I move joystick right it presses right key till I leave the joystick. The thing I want to do is move the joystick right, send the key once. No repeat keys.
Let's say right joystick = "a" key (no repeat)
Thanks |
|
| Back to top |
|
 |
randallf
Joined: 06 Jul 2009 Posts: 678
|
Posted: Sat Feb 20, 2010 3:51 am Post subject: |
|
|
| Anonymous wrote: | If I move joystick right it presses right key till I leave the joystick. The thing I want to do is move the joystick right, send the key once. No repeat keys.
Let's say right joystick = "a" key (no repeat)
Thanks |
| Code: | ; Otherwise, release the previous key and press down the new key:
SetKeyDelay -1 ; Avoid delays between keystrokes.
if KeyToHoldDownPrev ; There is a previous key to release.
Send, {%KeyToHoldDownPrev% up} ; Release it.
if KeyToHoldDown ; There is a key to press down.
Send, {%KeyToHoldDown% down} ; Press it down.
return |
Remove the 'up' and 'down' words. This should change it to a single send.
You may need to remove the 'up' line entirely and just change the down line to remove 'down'.
Is this for star trek online?
Also don't let the variable names 'keytoholddown' confuse you, it could just as easily be named 'key'. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|