If Image/Text found then x,y,z *basic* HOW?!

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
KyoDemon
Newbie
Posts: 3
Joined: Sun Apr 03, 2016 7:15 pm

If Image/Text found then x,y,z *basic* HOW?!

Post by KyoDemon » Sun Apr 03, 2016 7:23 pm

I apologize if this has been mentioned many times, however, I went through the forum and could not find the exact thing that I am looking for. This is probably a very basic script but I have been stuck on it for hours trying to think of WHY it's not working.

What I want to do: is when the "image/text" is found please click at this coordinate, then this coordinate and then rinse and repeat ONLY when the image/text appear again. In other words, stop clicking until the image/text appears and then click twice. That's it. I'm working on a very old crappy laptop and I don't want to destroy it from excessive clicking overnight.

What I have so far:
//Find and Left Click Center of
FindImagePos>%BMP_DIR%\image_4.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
MouseMove>XArr_0,YArr_0
LClick
Endif

MouseMove>XArr_0,YArr_0
LClick

MouseMove>715,674
LClick

Let>NumFound=0
While>NumFound=0
FindImagePos>%BMP_DIR%\\image_4.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
EndWhile

Thank you very much for helping me out! Much, much appreciated!

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: If Image/Text found then x,y,z *basic* HOW?!

Post by Marcus Tettmar » Tue Apr 05, 2016 10:28 am

I think all you really want is something like this:

Code: Select all

Label>mainloop

FindImagePos>%BMP_DIR%\image_4.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
If>NumFound>0
  MouseMove>XArr_0,YArr_0
  LClick
  
  MouseMove>XArr_0,YArr_0
  LClick
  
  MouseMove>715,674
  LClick
Endif

Wait>0.02
Goto>mainloop
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

KyoDemon
Newbie
Posts: 3
Joined: Sun Apr 03, 2016 7:15 pm

Re: If Image/Text found then x,y,z *basic* HOW?!

Post by KyoDemon » Sun Apr 10, 2016 9:27 pm

@Marcus Tettmar

Hello! Thanks so much for replying to me :). I tried the code that you sent back to me but for some reason Label>mainloop and Goto>mainloop are in red, stating that it doesn't work. I was also wondering if this loop would be infinite until I stop it with Ctrl+F2 or would I have to add a Stop Function, i.e. Repeat>??? Until>???

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: If Image/Text found then x,y,z *basic* HOW?!

Post by Marcus Tettmar » Mon Apr 11, 2016 3:48 pm

Those lines WILL be in red. Label and Goto are syntax highlighted red by the editor.

Yes it will keep looping until you stop the script. There are several ways to stop a script manually - either from the interface or via sytem wide shortcut SHIFT+CTRL which you can change under Tools/Options if you wish.

You can make your own handler within the script to stop it using a custom shortcut key using OnEvent but there's no need as you can do the above.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

KyoDemon
Newbie
Posts: 3
Joined: Sun Apr 03, 2016 7:15 pm

Re: If Image/Text found then x,y,z *basic* HOW?!

Post by KyoDemon » Mon Apr 11, 2016 8:40 pm

@Marcus Tettmar

My sincere apologies, the text being red made me remember the course I took in university for C++ and debugging the text in red.

Everything works like clockwork and I am extremely grateful, I prefer your option of just manually turning it off.

Thank you so much, this stuff is ingenious!

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