wait for image and loops

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Posts: 2
Joined: Mon Mar 22, 2021 1:45 pm

wait for image and loops

Post by frankods » Mon Mar 22, 2021 2:22 pm

I am looking for a way to loop waitscreenimage so continue clic a position until the image is found on screen;
when i write on screen i realy mean on screen i dont wanne take a screen schot and then look for the image inside the image...writing to hd is slow and is taxing for my ssd drive cuz its not 1 image buth hunderds of high resolution images and the script wil run 24 hours a day 7 days a week.

since waitscreenimage does not seem to return a value when it found the image its impossible to asssign that value to a variable.so i did next best thing after waitscreenimage finds the image mouse goes to a certain screen position that position is asigned to a variable so if mouse is not at givin position the loop needs to repeet and mouse hes to be cliced loop repeets until image found.

Code that i have so far is below.
can you help me been at it for hours cant make it work.


User avatar
Dorian (MJT support)
Automation Wizard
Posts: 923
Joined: Sun Nov 03, 2002 3:19 am

Re: wait for image and loops

Post by Dorian (MJT support) » Mon Mar 22, 2021 3:37 pm

My understanding is that you want to click the mouse at a given position until an image is visible. This will click at 1340,218, wait 1 seconds, then look for your r2 image. If that image is found it will exit the loop. If it is not found, it will mousemove, click, wait 1 second, and look again. Notice I have used a tolerance of 0.7. You can find an explanation of that here.

CCOEFF:Tolerence should be given a value between 0 and 1 where 1 is a precise match and 0 is the least precise. A value of 0.7 is recommended and should allow for subtle variations in the images and works best for portability. The lower the value the more likely false positives will be observed. With CCOEFF matching only one match (if any) is returned - the most likely candidate. CCOEFF will work with bitmap or png files.

This is one way to do it. I hope I am understanding correctly.

Code: Select all

I respectfully encourage you to look at the usage examples we provide for every command. That will help you understand the usage and syntax. Pressing F1 in the editor will take you to the help page for that command.
Yes, we have a Custom Scripting Service. Message me or go here

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts