Help with Variation Loop Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
guilhermevs91
Posts: 5
Joined: 03 Apr 2018, 11:54
Facebook: Guilherme Vieira
Google: Guilherme Vieira
GitHub: Guilherme

Help with Variation Loop

29 Jun 2018, 10:45

Hello, gentlemen!

I would like to help with the following: I need to create a loop that when I press the F1 key, it is alternating between F8, F7, F8, F6 and restart, but I need to press it again to stop where it is. Example: Press F1. It will loop the F8, F7, F8, F6, F8, F7 and if I press the F1 again it will stop at that time and not finish the sequence. Would it be possible? detail that should have a time of 1 second between each key.

Thanks a lot for the help.
Sorry for the translator's english :)
Rohwedder
Posts: 2054
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Help with Variation Loop  Topic is solved

29 Jun 2018, 22:30

Hallo,
try:

Code: Select all

Keys = {F8},{F7},{F8},{F6}
Keys := StrSplit(Keys,",")
Return
F1:: ;Send Keys On/Off with key F1
    If F4Active:=!F4Active
        SetTimer SendKeys, 1000 ;1000 ms delay between keys
    Else
        SetTimer SendKeys, Off
Return
SendKeys:
    Counter := Mod(0 Counter,Keys.MaxIndex())+1
    Send, % Keys[Counter]
Return
guilhermevs91
Posts: 5
Joined: 03 Apr 2018, 11:54
Facebook: Guilherme Vieira
Google: Guilherme Vieira
GitHub: Guilherme

Re: Help with Variation Loop

30 Jun 2018, 13:19

Hi, thanks for the feedback, I took the test here and it did not work, do you have any other ideas?

Thanks for help!
Rohwedder wrote:Hallo,
try:

Code: Select all

Keys = {F8},{F7},{F8},{F6}
Keys := StrSplit(Keys,",")
Return
F1:: ;Send Keys On/Off with key F1
    If F4Active:=!F4Active
        SetTimer SendKeys, 1000 ;1000 ms delay between keys
    Else
        SetTimer SendKeys, Off
Return
SendKeys:
    Counter := Mod(0 Counter,Keys.MaxIndex())+1
    Send, % Keys[Counter]
Return
User avatar
Xtra
Posts: 1370
Joined: 02 Oct 2015, 12:15

Re: Help with Variation Loop

30 Jun 2018, 14:35

Example:

Code: Select all

#NoEnv

F1::
    SetTimer SendKeys, % (t:=!t) ? 1000 : "Off"
    Counter := toggle := 0
Return

SendKeys:
    Send, %  Mod(++Counter,2) ? "{F8}" : (toggle:=!toggle) ? "{F7}" : "{F6}"
Return
HTH
guilhermevs91
Posts: 5
Joined: 03 Apr 2018, 11:54
Facebook: Guilherme Vieira
Google: Guilherme Vieira
GitHub: Guilherme

Re: Help with Variation Loop

30 Jun 2018, 14:36

I re-did the test and it worked!
SORRY!! AND THANK YOU SO MUCH!!

guilhermevs91 wrote:Hi, thanks for the feedback, I took the test here and it did not work, do you have any other ideas?

Thanks for help!
Rohwedder wrote:Hallo,
try:

Code: Select all

Keys = {F8},{F7},{F8},{F6}
Keys := StrSplit(Keys,",")
Return
F1:: ;Send Keys On/Off with key F1
    If F4Active:=!F4Active
        SetTimer SendKeys, 1000 ;1000 ms delay between keys
    Else
        SetTimer SendKeys, Off
Return
SendKeys:
    Counter := Mod(0 Counter,Keys.MaxIndex())+1
    Send, % Keys[Counter]
Return
Noo0B
Posts: 73
Joined: 26 Jan 2018, 19:54

Re: Help with Variation Loop

01 Jul 2018, 01:37

Hi,
I'm glad you got it working.
I came up to a code for more general situations, it's something like this:

Code: Select all

F4::
Toggle:= !toggle
	If Toggle {
		While Toggle {
			; code
		}
	Return
	}
	If !Toggle
		; code
		Return
EDIT:
I thought it was doing an extra line within the while-loop code after toggled off, but I could not replicate.
So it's good.
Regards

Return to “Ask For Help”

Who is online

Users browsing this forum: Dumitas, gregor_, ilhom, swagfag, TheAlmightyDada, vsub, WeThotUWasAToad and 233 guests