Loop with +1 each time the loop occurs?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Esoeth
Posts: 2
Joined: 22 Jan 2018, 03:22

Loop with +1 each time the loop occurs?

22 Jan 2018, 03:29

Hi,

I'm brand new to AHK in general and I'm testing out AHK to make a script to basically negate 20% of the work I do daily.

The code is fairly basic, maybe even stupid but this is what I have now:

Code: Select all

InputBox, loopCount,,Enter a number for loop count

loop, %loopCount%
{

Send {Ctrl down}n{ctrl up}
	Sleep 300
	Send DIV-73
	Send {TAB down}{TAB up}
	Send {1}
	Send {TAB down}{TAB up}
	Sleep 5000
	Send ^{down}                  ;This one
	Send {TAB down}{TAB up}
	Send {TAB down}{TAB up}
	Send {enter}
	Sleep 300
Send {Ctrl down}n{ctrl up}
	Sleep 300
	Send DIV-1086
	Send {TAB down}{TAB up}
	Send 1
	Send {TAB down}{TAB up}
	Sleep 5000
	Send ^{down}                  ;This one
	Send {TAB down}{TAB up}
	Send {TAB down}{TAB up}
	Send {enter}
	Sleep 300
Send {Ctrl down}n{ctrl up}
	Sleep 300
	Send 1248
	Send {TAB down}{TAB up}
	Send 1
	Send {TAB down}{TAB up}
	Sleep 5000
	Send ^{down}                  ;This one
	Send {TAB down}{TAB up}
	Send {TAB down}{TAB up}
	Send {enter}
	Sleep 300
						}
Return
What I wish for is that if I run this script and chose to loop it say, 80 times, I wish to add ^{down} to those lines called "This one" each loop.
So first loop its 1x ^{down}, second loop it's ^{down}^{down}, third it's ^{down}^{down}^{down} etc all the way until 80 times. The loop will vary from 1-4 upwards to a total of 250-ish?

Hope this is understandable at all and hope someone can help me!

Best regards,
Jonas
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Loop with +1 each time the loop occurs?

22 Jan 2018, 03:35

Code: Select all

InputBox, loopCount,,Enter a number for loop count

loop, %loopCount%
{

Send {Ctrl down}n{ctrl up}
	Sleep 300
	Send DIV-73
	Send {TAB down}{TAB up}
	Send {1}
	Send {TAB down}{TAB up}
	Sleep 5000
	Send ^{down %A_Index%}                  ; Check the AHK help for this generic variable (simply click on it within this/the forums code box)
	Send {TAB down}{TAB up}
	Send {TAB down}{TAB up}
	Send {enter}
	Sleep 300
Send {Ctrl down}n{ctrl up}
	Sleep 300
	Send DIV-1086
	Send {TAB down}{TAB up}
	Send 1
	Send {TAB down}{TAB up}
	Sleep 5000
	Send ^{down %A_Index%}                  ; see above
	Send {TAB down}{TAB up}
	Send {TAB down}{TAB up}
	Send {enter}
	Sleep 300
Send {Ctrl down}n{ctrl up}
	Sleep 300
	Send 1248
	Send {TAB down}{TAB up}
	Send 1
	Send {TAB down}{TAB up}
	Sleep 5000
	Send ^{down %A_Index%}                  ; see above
	Send {TAB down}{TAB up}
	Send {TAB down}{TAB up}
	Send {enter}
	Sleep 300
						}
Return
Not tested.
Esoeth
Posts: 2
Joined: 22 Jan 2018, 03:22

Re: Loop with +1 each time the loop occurs?

22 Jan 2018, 03:51

Hi again!

Thanks BoBo!

That seems to work, haven't quite been able to test it properly yet.

But! Is it possible to add a sleep in that bracket? ^{down sleep 50 %A_Index%} ?

Or how can I properly do that?

Regards,
Jonas
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Loop with +1 each time the loop occurs?

22 Jan 2018, 04:16

But! Is it possible to add a sleep in that bracket? ^{down sleep 50 %A_Index%} ?
Quite easy to sort this out. Read the help about Send. As already said, click on whatever command of your interest within the forums code box and you're done! And, btw it's as easy as to click [this]

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: mikeyww, ReyAHK and 267 guests