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