waitpixelcolor

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
junaidali15
Newbie
Posts: 3
Joined: Sun Jan 15, 2017 1:01 am

waitpixelcolor

Post by junaidali15 » Sun Jan 15, 2017 1:05 am

i want to add condition in waitpixelcolor
basically i want script to keep looking for 2 different cordinates for different colors... if 1st come it will do something and if 2nd come it will do another thing

like if waitpixelcolor>0,111,111,0
say hi
ifelse waitpixelcolor>1,222,222,0
say hello..

means which will come first it do that work

any idea how to do

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

Re: waitpixelcolor

Post by Marcus Tettmar » Mon Jan 16, 2017 11:38 am

Since WaitPixelColor waits you can't wait for two at once, so instead use GetPixelColor in a loop:

Code: Select all

Label>loop
  GetPixelCOlor>X1,Y1,color1
  GetPixelColor>X2,Y2,color2
  If>color1=whatever1
    MessageModal>hi
  Endif
  If>color2=whatever2
    MessageModal>hello
  Endif
  Wait>0.02
Goto>loop
So this keeps looking at two different coordinates and checking what colours are there. It does something if either matches and then continues to loop. This example loops forever but you could make it stop based on some condition. Whatever you want.

If you think about it WaitPixelColor is really just GetPIxelColor in a loop, so that's what you need - a loop with two GetPixelColors in it where you check for two different positions/colours ...
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

junaidali15
Newbie
Posts: 3
Joined: Sun Jan 15, 2017 1:01 am

Re: waitpixelcolor

Post by junaidali15 » Tue Jan 17, 2017 5:19 pm

thanks for this it helped but i want to add subcondition with both conditions and then want to restart whole script
like
label>start
if>color=0
gosub>done
endif
if>color=1
gosub>notdone
endif
srt>done
anything
goto>start
end>done

but its giving me errorbranching out of aubroutine is not recommended

User avatar
CyberCitizen
Automation Wizard
Posts: 721
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Re: waitpixelcolor

Post by CyberCitizen » Mon Jan 23, 2017 1:14 am

What about not going to a subroutine and just include it in the match.

label>start
if>color=0
Let>vSomething=Something
Goto>Start
endif
if>color=1
gosub>notdone
endif
end>done
FIREFIGHTER

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