Repeat command
-
- Posts: 2
- Joined: 26 Jan 2023, 16:08
Repeat command
I have a macro that is entirely image search and then click image. I have a problem though where sometimes a page loads slow. The macro will click the image when it appears, but since the page wasn't fully loaded then clicking the image doesn't do anything. This prevents the image in the next step from popping up so now the next step can't activate. I'm trying to either get step 1 to repeat if step 2 doesn't activate after x seconds or get step 1 to keep repeating until it's image is gone. I tried a "repeat until not found" command, but it isn't working. What's the best way to do this?
-
- Posts: 47
- Joined: 26 Mar 2019, 06:06
Re: Repeat command
not sure what the best way is but what if you did one image search to find the target then when it finds the target wait sleep 2000 then have it search a 2nd time to find it and click it
Re: Repeat command
Welcome to this AutoHotkey forum!
There are also posts on this forum that show some different approaches to determining when the page has loaded.
There are also posts on this forum that show some different approaches to determining when the page has loaded.
Re: Repeat command
You can try something like this: (change out the placeholders to what your code is.)I'm trying to either get step 1 to repeat if step 2 doesn't activate after x seconds
Code: Select all
Loop
{
ImageSearch, image1X, image1Y, X1, Y1, X2, Y2, ImageFile1
if (ErrorLevel = 0) {
MouseClick, Left, image1X, image1Y ; click image1
Loop, 10 ; Allow upto 10 trys/seconds before clicking image1 again.
{
Sleep 1000
ImageSearch, image2X, image2Y, X1, Y1, X2, Y2, ImageFile2
if (ErrorLevel = 0) {
break, 2 ; break outer loop when 2nd image is found.
}
}
}
}
-
- Posts: 2
- Joined: 26 Jan 2023, 16:08
Re: Repeat command
I've added a delay to give the page time to load, but sometimes it's especially slow and that delay isn't good enough. This is a macro I have run on repeat so having an over 5 second delay there every time really slows it down in the long run.NewberEnerNeeder1 wrote: ↑26 Jan 2023, 17:45not sure what the best way is but what if you did one image search to find the target then when it finds the target wait sleep 2000 then have it search a 2nd time to find it and click it
-
- Posts: 47
- Joined: 26 Mar 2019, 06:06
Re: Repeat command
maybe just image search something that fully loads on the page THEN once that thing loads have it search for the main searchJessiebnyc wrote: ↑26 Jan 2023, 19:09I've added a delay to give the page time to load, but sometimes it's especially slow and that delay isn't good enough. This is a macro I have run on repeat so having an over 5 second delay there every time really slows it down in the long run.NewberEnerNeeder1 wrote: ↑26 Jan 2023, 17:45not sure what the best way is but what if you did one image search to find the target then when it finds the target wait sleep 2000 then have it search a 2nd time to find it and click it