Does anyone have a quick piece of code to assign cycling of keystrokes to one key?
i.e. I'd like to press, say, the F7 key and each time I do it cycles between sending different single keys.
example:
I press F7 the first time // AHK sends '3'
I press F7 the second time // AHK sends '4'
I press F7 a third time // AHK sends '5'
then it resets so that if you pressed it a fourth time, it would start the above process over.
I'm at work right now and can't install AHK to give it a go here.
Thanks in advance,
Cycling keystrokes?
Re: Cycling keystrokes?
Code: Select all
cycle(start, step) {
static i := 0
return Mod((++i - 1), step) + start
}
F7::Send % cycle(3, 3)
Esc::ExitApp
Re: Cycling keystrokes?
First with ByRef parameter:
Code: Select all
Current := 0
F7:: Send, % Cycle(Current)
Cycle(ByRef Count) {
Return, Count -= (++Count > 3) ? 3 : 0
}
Code: Select all
global Count := 0
F7:: Send, % Cycle()
Cycle() {
Return, Count -= (++Count > 3) ? 3 : 0
}
Re: Cycling keystrokes?
It's ugly as hell, but just to practice ternary operator:
Code: Select all
F7::Send % (c = 5) ? (c := 3) : (c = 3) ? (c := 4) : (c = 4) ? (c := 5) : (c := 3)
Re: Cycling keystrokes?
this isnt practice, this is abuse lol
Re: Cycling keystrokes?
I agree.swagfag wrote:this isnt practice, this is abuse lol
Re: Cycling keystrokes?
Haha!
Thanks, everyone.
They all work great and I appreciate the help.
Thanks, everyone.
They all work great and I appreciate the help.
Re: Cycling keystrokes?
Kryu wrote: but just to practice ternary operator:
Code: Select all
F7::Send % c := c=3 ? 4 : c=4 ? 5 : 3
Re: Cycling keystrokes?
Thanks!Xtra wrote:Kryu wrote: but just to practice ternary operator:Code: Select all
F7::Send % c := c=3 ? 4 : c=4 ? 5 : 3
Who is online
Users browsing this forum: No registered users and 55 guests