If specific color excist > do this - If not > skip

Discuss RoboTask here
Post Reply
snowseals
Posts: 59
Joined: Mon Apr 11, 2016 10:17 am

If specific color excist > do this - If not > skip

Post by snowseals »

Happy new year Oleg!

I'm trying to figure out , How to move to object + click and & delay - ONLY if specific color excists.
If not, skip (and just continue).
So far I've tried using Color Compliance and If Then / Else Then, but I cant seem to get it working.

Basically, it boils down to this:
Depending on the input of data, a website pops up a blue-button somewhere on the screen, or not.
The times it doesnt pop up it should skip the handling afterwards (to click this button and continue)
The times it does pop up it should click this button and continue.

See also: https://youtu.be/K7e_MvQX-sM

How to create such script?
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: If specific color excist > do this - If not > skip

Post by Oleg »

You have to get the pixel from necessary place of the screen (not window use full screen)
Make comparison with Color compliance action. This action save TRUE or FALSE into your variable
Next, use If..Then action
Oleg Yershov
snowseals
Posts: 59
Joined: Mon Apr 11, 2016 10:17 am

Re: If specific color excist > do this - If not > skip

Post by snowseals »

Like this?

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|0
CatID=INTEGER|0
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task1111"
Hide=INTEGER|0
ID=INTEGER|1830696294
LogOnAsUser=INTEGER|1
Name=STRING|"If color = blue do this, else do that"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|0
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""COLORMATCHED"" with value ""false"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"COLORMATCHED"
varvalue=STRING|"false"

[Actions\Action2]
ActionID=STRING|"A_SCR_SCRPIXEL"
Enabled=INTEGER|-1
Name=STRING|"Screen Pixel"
Params=FOLDER

[Actions\Action2\Params]
variable=STRING|"color"
x=STRING|"668"
y=STRING|"585"

[Actions\Action3]
ActionID=STRING|"A_SCR_COLORCOMPLIANCE"
Enabled=INTEGER|-1
Name=STRING|"Color Compliance"
Params=FOLDER

[Actions\Action3\Params]
color1=STRING|"{color}"
color2=STRING|"$00DD8833"
tolerance=STRING|"5"
variable=STRING|"ColorMatched"

[Actions\Action4]
ActionID=STRING|"A_GENERAL_PAUSE"
Enabled=INTEGER|-1
Name=STRING|"Delay 1 sec"
Params=FOLDER

[Actions\Action4\Params]
delay=STRING|"1"
dimension=STRING|"1"

[Actions\Action5]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER

[Actions\Action5\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"1"
type=STRING|"3"
value1=STRING|"{ColorMatched}"

[Actions\Action6]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""Point color is not blue."""
Params=FOLDER

[Actions\Action6\Params]
icon=STRING|"1"
msg0=STRING|"Point color is not blue."
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action7]
ActionID=STRING|"A_FLOW_ELSE"
Enabled=INTEGER|-1
Name=STRING|"Else"

[Actions\Action8]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""Point color is blue!"""
Params=FOLDER

[Actions\Action8\Params]
icon=STRING|"1"
msg0=STRING|"Point color is blue!"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action9]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"

Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: If specific color excist > do this - If not > skip

Post by Oleg »

Yes. It seems the algorithm of your example is correct.
But I think that step #4 (Delay 1 sec) has no sense.
Oleg Yershov
snowseals
Posts: 59
Joined: Mon Apr 11, 2016 10:17 am

Re: If specific color excist > do this - If not > skip

Post by snowseals »

I'll try in a bit implementing this in excisting script.

I put that Delay 1 sec in it, since it's not instantly showing that pop-up/blue button after u press a button (that will either show or not show the pop-up popping) ;)
Hence I believe I need to use the Delay, otherwise, it will right away tell me there's no such blue pixel.
Oleg
Site Admin
Posts: 3000
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Re: If specific color excist > do this - If not > skip

Post by Oleg »

In this case you have to put delay before screen pixel action

The delay has no sense if you already get the color from screen.
Oleg Yershov
snowseals
Posts: 59
Joined: Mon Apr 11, 2016 10:17 am

Re: If specific color excist > do this - If not > skip

Post by snowseals »

Yep, u right! Thanks :)

Script = working like this now:

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|0
CatID=INTEGER|0
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task1111"
Hide=INTEGER|0
ID=INTEGER|1830696294
LogOnAsUser=INTEGER|1
Name=STRING|"If color = blue do this, else do that (imported)"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|0
WriteGeneralLog=INTEGER|0

[Actions]
Action1=FOLDER
Action10=FOLDER
Action11=FOLDER
Action12=FOLDER
Action13=FOLDER
Action14=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""COLORMATCHED"" with value ""false"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"COLORMATCHED"
varvalue=STRING|"false"

[Actions\Action10]
ActionID=STRING|"A_MOUSE_CLICK"
Enabled=INTEGER|-1
Name=STRING|"Click button"
Params=FOLDER

[Actions\Action10\Params]
action=STRING|"0"
button=STRING|"0"

[Actions\Action11]
ActionID=STRING|"A_MISC_COMMENT"
Enabled=INTEGER|-1
Name=STRING|"//End of MacroRecoder block"
Params=FOLDER

[Actions\Action11\Params]
comment=STRING|"End of MacroRecoder block"

[Actions\Action12]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|0
Name=STRING|"Show ""Point color is blue!"""
Params=FOLDER

[Actions\Action12\Params]
icon=STRING|"1"
msg0=STRING|"Point color is blue!"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action13]
ActionID=STRING|"A_SCR_WAITFORPIXELS"
Enabled=INTEGER|-1
Name=STRING|"Wait for Pixels (full screen)"
Params=FOLDER

[Actions\Action13\Params]
caption=STRING|"1"
class=STRING|"0"
classexact=STRING|"0"
color0000=STRING|"$00EDF1F2"
comparemode=STRING|"0"
exact=STRING|"0"
findmode=STRING|"0"
infinity=STRING|"0"
pxcount=STRING|"1"
source=STRING|"1"
timeout=STRING|"60"
tolerance0000=STRING|"16"
x0000=STRING|"904"
y0000=STRING|"695"

[Actions\Action14]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"

[Actions\Action2]
ActionID=STRING|"A_SCR_SCRPIXEL"
Enabled=INTEGER|-1
Name=STRING|"Screen Pixel"
Params=FOLDER

[Actions\Action2\Params]
variable=STRING|"color"
x=STRING|"906"
y=STRING|"695"

[Actions\Action3]
ActionID=STRING|"A_SCR_COLORCOMPLIANCE"
Enabled=INTEGER|-1
Name=STRING|"Color Compliance"
Params=FOLDER

[Actions\Action3\Params]
color1=STRING|"{color}"
color2=STRING|"$00DD8833"
tolerance=STRING|"5"
variable=STRING|"ColorMatched"

[Actions\Action4]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER

[Actions\Action4\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"1"
type=STRING|"3"
value1=STRING|"{ColorMatched}"

[Actions\Action5]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|0
Name=STRING|"Show ""Point color is not blue."""
Params=FOLDER

[Actions\Action5\Params]
icon=STRING|"1"
msg0=STRING|"Point color is not blue."
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action6]
ActionID=STRING|"A_LOOP_BREAK"
Enabled=INTEGER|-1
Name=STRING|"Break"

[Actions\Action7]
ActionID=STRING|"A_FLOW_ELSE"
Enabled=INTEGER|-1
Name=STRING|"Else"

[Actions\Action8]
ActionID=STRING|"A_MISC_COMMENT"
Enabled=INTEGER|-1
Name=STRING|"//Begin of MacroRecoder block"
Params=FOLDER

[Actions\Action8\Params]
comment=STRING|"Begin of MacroRecoder block"

[Actions\Action9]
ActionID=STRING|"A_MOUSE_MOVETO"
Enabled=INTEGER|-1
Name=STRING|"Move To Object"
Params=FOLDER

[Actions\Action9\Params]
bottom=STRING|"1040"
controlclass=STRING|"Chrome_RenderWidgetHostHWND"
controltext=STRING|"Chrome Legacy Window"
ctrltextexact=STRING|"1"
left=STRING|"0"
right=STRING|"1920"
top=STRING|"130"
windowclass=STRING|"Chrome_WidgetWin_1"
windowtext=STRING|"AutotelexPRO - Google Chrome"
wintextexact=STRING|"0"
x=STRING|"910"
y=STRING|"562"
Post Reply