Repeat command until find an image.

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
marares
Newbie
Posts: 9
Joined: Wed Mar 16, 2016 1:06 am

Repeat command until find an image.

Post by marares » Sun Mar 27, 2016 10:03 pm

I'll begin with a sorry because probably I would post into a beginners section inside this beginners section if there was one.

I'd like for MacroScheduler to keep sending a command until it finds an certain image.

I really looked for it, but since I'm not a programmer, my mind won't make me go to the right places.

Could anyone help me?

Thanks.

User avatar
Meryl
Staff
Posts: 124
Joined: Wed Sep 19, 2012 1:53 pm
Location: Texas
Contact:

Re: Repeat command until find an image.

Post by Meryl » Mon Mar 28, 2016 2:36 pm

Just came across this ... does this give you an idea?

viewtopic.php?f=8&p=39593#p39593

marares
Newbie
Posts: 9
Joined: Wed Mar 16, 2016 1:06 am

Re: Repeat command until find an image.

Post by marares » Mon Mar 28, 2016 6:54 pm

Thanks, Meryl. I think that's not it.

My newbie research makes me stumble upon the repeat and until commands.

But I don't understand how to use them.

I feel that what I want to do is pretty simple but i can't do even that :)

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

Re: Repeat command until find an image.

Post by Marcus Tettmar » Tue Mar 29, 2016 8:21 am

Hi,

If you are new to looping I would recommend this article:
http://help.mjtnet.com/article/144-how-to-loop-the-loop

I'm assuming by "find an image" you are using the FindImagePos function. This returns the number of images found. We'll use NumFound for that. So you would want to Repeat, Until NumFound is greater than zero. See, when you say it like that it's just plain English.

Code: Select all

Let>numFound=0
Repeat>NumFound
  FindImagePos>%BMP_DIR%\image_1.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
Until>NumFound>0
Or you could use a While loop which says While NumFound is zero, keep looking.

Code: Select all

Let>NumFound=0
While>NumFound=0
  FindImagePos>%BMP_DIR%\image_1.bmp,SCREEN,0.7,1,XArr,YArr,NumFound,CCOEFF
EndWhile
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

marares
Newbie
Posts: 9
Joined: Wed Mar 16, 2016 1:06 am

Re: Repeat command until find an image.

Post by marares » Wed Mar 30, 2016 10:47 pm

Thanks, Marcus.
I gave it a look and i think that might be it.
Thanks a lot!

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