Technical support and scripting issues
Moderators: JRL, Dorian (MJT support)
-
gnastie
- Newbie
- Posts: 5
- Joined: Thu May 14, 2020 3:38 am
Post
by gnastie » Tue May 19, 2020 10:13 pm
So basically I have a script that goes like this
- Label>BC
FindImagePos>%BMP_DIR%\image_3.bmp,SCREEN,0.7,1,XArr,YArr,AC,CCOEFF
If>AC>0
Wait>.75
MouseMove>XArr_0,YArr_0
LClick
Endif
If>AC=0
Goto>BC
Endif
Wait>.5
So it essentially continues searching for an image until the image is there since if the image isn't present, it just reverts back to the "FindImagePos" command and proceeds to look for the image and so on. I don't like using the "Wait for an image to appear before continuing" just because it seemed a little finicky whenever I initially tried it.
My question: How should I make the script look for the image for say 5 seconds, and proceed on if the image is unable to be found.
Thanks so much,
Isaac
-
Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
-
Contact:
Post
by Marcus Tettmar » Wed May 20, 2020 6:43 am
WaitScreenImage *CONTAINS* FindImagePos in a loop. That's all WaitScreenImage is - essentially it is exactly what you have. It's a loop with FindImagePos in it. They aren't just the SAME implementation - WaitScreenImage *IS* FindImagePos.
And with WaitScreenImage you can set a timeout. So the simplest solution would be just to use WaitScreenImage with a timeout. Hopefully what I've said above allays any concerns - it cannot possibly be more 'finnicky' than FindImagePos. It literally *IS* FindImagePos.
However, if you wanted to reinvent the wheel you could simply check for elapsed time in your loop. Look at the Timer> command.
You might want to consider using a Repeat/Until or While/EndWhile instead of the labels, gotos and ifs that you have right now.
-
gnastie
- Newbie
- Posts: 5
- Joined: Thu May 14, 2020 3:38 am
Post
by gnastie » Wed May 20, 2020 6:01 pm
Alright, I think I'll just go with the WaitScreenImage timeout option. Thanks.