Script is supposed to loop but won't
Posted: 21 Nov 2020, 06:01
I've run into a problem with my code that I've been unable to solve, would appreciate any advice.
The script is supposed to go to a website and perform a sequence several times as defined by RetrieveNum, then after completing that many repetitions it waits as defined by waitNum, then performs several batches of those sequences as defined by batchNum. The script gets to "MsgBox Increasing batch" and then never loops. I assumed it was an issue with the while sequence, but if so I can't figure out what it is.
Sorry that this is my third question in the last week or two. I've been getting really into learning AHK but sometimes I get stuck and figured asking would be better than spending another day or two staring at the code when I could be spending that time trying to understand what I did wrong.
The script is supposed to go to a website and perform a sequence several times as defined by RetrieveNum, then after completing that many repetitions it waits as defined by waitNum, then performs several batches of those sequences as defined by batchNum. The script gets to "MsgBox Increasing batch" and then never loops. I assumed it was an issue with the while sequence, but if so I can't figure out what it is.
Sorry that this is my third question in the last week or two. I've been getting really into learning AHK but sometimes I get stuck and figured asking would be better than spending another day or two staring at the code when I could be spending that time trying to understand what I did wrong.
Code: Select all
RepProfilesFromEntryToSpreadsheet()
{
InputBox, entryVal, entry to rep, What entry?
InputBox, repNum, Number of reps, How many entries for each batch?
InputBox, waitMin, How long to wait, How many minutes should we wait between batches?
InputBox, batchNum, How many batches, How many batches?
waitNum := waitMin*60000
batchCount = 0
currentNum = 0
websiteTagUrl = https www.website.com / Broken Link for safety
sleep %shortSleep%
CheckCorrectProfile(correctProfile)
currentNum = 1
countTemp = 0
Send ^t
sleep %mediumSleep%
Send ^l
sleep %shortSleep%
Send %websiteTagUrl%
sleep %shortSleep%
Send %entryVal%
sleep %shortSleep%
Send {enter}
sleep %longSleep%
while (currentNum < repNum && batchCount < batchNum)
{
MsgBox Starting sequence
Send ^f
sleep %shortSleep%
Send rep
sleep %shortSleep%
Send {tab}
sleep %shortSleep%
Send {tab}
sleep %shortSleep%
Send {tab}
sleep %shortSleep%
Send {enter}
while (countTemp < currentNum)
{
Send {tab}
sleep %shortSleep%
countTemp++
}
countTemp = 0
Send {enter}
if (currentNum == 1)
{
countTempGoal = 3
}
else
{
countTempGoal = 4
}
while (countTemp < countTempGoal)
{
Send {tab}
sleep %shortSleep%
countTemp++
}
countTemp = 0
RightClickAndCopyUrl()
sleep %shortSleep%
sleep %shortSleep%
currentUserRaw = %clipboard%
sleep %shortSleep%
StringTrimLeft, currentUserTemp, currentUserRaw, 26
StringTrimRight, currentUser, currentUserTemp, 1
sleep %shortSleep%
Send {tab}
sleep %shortSleep%
Send {enter}
sleep %shortSleep%
Send {escape}
sleep %shortSleep%
Send {Shift Down}{Ctrl Down}{tab}{Ctrl Up}{Shift Up}
sleep %shortSleep%
Send %currentUser%
sleep %shortSleep%
Send {tab}
sleep %shortSleep%
Send reped
sleep %shortSleep%
Send {enter}
sleep %shortSleep%
Send {Ctrl Down}{tab}{Ctrl Up}
sleep %mediumSleep%
MsgBox currentNum is %currentNum% repNum is %repNum% batchCount is %batchCount% batchNum is %batchNum%
if (currentNum == repNum)
{
MsgBox Increasing batch
batchCount++
currentNum = 0
sleep %waitNum%
if (batchCount == batchNum)
{
MsgBox Finishing
Send ^w
MsgBox Completed successfully.
return
}
}
else
{
MsgBox Increasing current num
currentNum++
return
}
}
}