How To Stop Auto-Repeat Behavior Of Hotkey? Topic is solved
How To Stop Auto-Repeat Behavior Of Hotkey?
I have a double-press script. I often hold down the LShift hotkey that activates it. When held down, the script often executes repeatedly. I assume because the LShift key is auto-repeated by Windows. Is there a way to halt this auto-repeat behavior, while still allowing the script to detect double presses? I found GetKeyState, KeyWait, If/Else, and Loop in the AHK Documentation, but have been unable to come up with any design that works for this specific situation.
Re: How To Stop Auto-Repeat Behavior Of Hotkey? Topic is solved
Feel free to post your script for feedback about it.
Code: Select all
LShift::
Click, 2
SoundBeep, 1500
KeyWait, LShift
SoundBeep, 1000
Return
Re: How To Stop Auto-Repeat Behavior Of Hotkey?
Thank you mikeyww, I might do that. Regarding the script you posted, when I hold down the LShift key, I hear those beeps repeating for as long as I hold LShift down. Is there a way to stop it from repeating? What I am after is:
1. Press LShift down and do not physically release it. The script executes only once.
2. I continue to hold LShift down for 30 seconds, but script does not fire a second or more times.
3. Finally, I release the LShift key. Then physically press it a second time. The script executes for a second time.
1. Press LShift down and do not physically release it. The script executes only once.
2. I continue to hold LShift down for 30 seconds, but script does not fire a second or more times.
3. Finally, I release the LShift key. Then physically press it a second time. The script executes for a second time.
Re: How To Stop Auto-Repeat Behavior Of Hotkey?
That's surprising because the hook is installed at my end, but you could add #InstallKeybdHook at the top. It works here. Use this exact script with no other code, and no other scripts running at the same time. Test in Notepad.
Re: How To Stop Auto-Repeat Behavior Of Hotkey?
I apologize. Your script does work perfectly. I had the AHK script I am working on running in the background, which utilizes LShift. So I changed the hotkey in your script from LShift to a. But I failed to update the KeyWait command. I closed all other AHK scripts like you suggested and now your script works flawlessly. And without needing to specify #InstallKeybdHook. I am sorry about that. Thank you so much for your help
Re: How To Stop Auto-Repeat Behavior Of Hotkey?
Good to hear. Thank you for the report. Have fun with it.