Saturday, December 24, 2016

keyboard shortcuts - AHK — How to interrupt alternate keys for same hotkey?



I have a code that every time I press the hotkey, a letter is sent.



Pressing Q, Q, Q, Q, Q is sent "a", "b", "c", "d", "e", respectively. Then the loop restarts.




For example: pressing Q 13 times sends "abcdeabcdeabc".



My question is:



How can I reset the loop and return to the first letter ("a") if I do not press Q for a few seconds?



My code:



q::
Send, % ["a","b","c","d","e"][(count >= 5 || !count)? count := 1 : ++count]

return

Answer



I found a solution by myself. I hope this can help someone in the future.



Good luck. :)



q::
Send, % ["a","b","c","d","e"][A_TimeSincePriorHotkey>2500 || A_PriorHotkey<>A_ThisHotkey || (count >= 5 || !count) ? count := 1 : ++count]
return


No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...