3 states: How do use it proper with 2 If , ElseIf statements

Discuss RoboTask here

3 states: How do use it proper with 2 If , ElseIf statements

Postby snowseals » Thu Sep 30, 2021 12:50 pm

I'm trying to run 3 different scripts, depending on the visual representation of a certain site.

There are 3 visual representations:
Image

I'm using Screen Pixel and Local Variables along with Color Compliance to decide which script to run.
It works, but sometimes it's still running the wrong script.

Image

What I'm I doing wrong?

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
DisableOnError=INTEGER|0
DoNotStopWhenShutdown=INTEGER|0
ExternalName=STRING|"Task16"
Hide=INTEGER|0
ID=INTEGER|1660370954
LogOnAsUser=INTEGER|1
Name=STRING|"05   AutotelexPRO invullen + Eurotax openen tm 2017 vs 2018 vs 2020 (imported)"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0

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

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

[Actions\Action1\Params]
monitor=STRING|"0"
useprimary=STRING|"1"
variable=STRING|"colorWhite"
x=STRING|"1159"
y=STRING|"429"

[Actions\Action10]
ActionID=STRING|"A_LOOP_BREAK"
Enabled=INTEGER|0
Name=STRING|"Break"

[Actions\Action11]
ActionID=STRING|"A_FLOW_ELSEIF"
Enabled=INTEGER|-1
Name=STRING|"ElseIf Then"
Params=FOLDER

[Actions\Action11\Params]
case=STRING|"0"
case#1=STRING|"0"
connection=STRING|"0"
count=STRING|"2"
operator=STRING|"0"
operator#1=STRING|"1"
type=STRING|"3"
type#1=STRING|"3"
value1=STRING|"{ColorMatcheda}"
value1#1=STRING|"{ColorMatchedb}"

[Actions\Action12]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|0
Name=STRING|"Show ""2018 - Point color is white but NOT beige."""
Params=FOLDER

[Actions\Action12\Params]
icon=STRING|"1"
msg0=STRING|"2018 - Point color is white but NOT beige."
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action13]
ActionID=STRING|"A_TASKS_START"
Enabled=INTEGER|-1
Name=STRING|"Start Task ""2018 - 05  AutotelexPRO invullen + Eurotax openen!"""
Params=FOLDER

[Actions\Action13\Params]
parametercount=STRING|"0"
required=STRING|"0"
taskid=STRING|"265965612"
wait=STRING|"1"

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

[Actions\Action15]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|0
Name=STRING|"Show ""2020 """
Params=FOLDER

[Actions\Action15\Params]
icon=STRING|"1"
msg0=STRING|"2020 "
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action16]
ActionID=STRING|"A_TASKS_START"
Enabled=INTEGER|-1
Name=STRING|"Start Task ""2021  05  AutotelexPRO invullen + Eurotax openen!"""
Params=FOLDER

[Actions\Action16\Params]
parametercount=STRING|"0"
required=STRING|"0"
taskid=STRING|"691894826"
wait=STRING|"1"

[Actions\Action17]
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]
monitor=STRING|"0"
useprimary=STRING|"1"
variable=STRING|"colorBeige"
x=STRING|"1162"
y=STRING|"446"

[Actions\Action3]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""COLORMATCHEDa"" with value ""whiteVariable"""
Params=FOLDER

[Actions\Action3\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"COLORMATCHEDa"
varvalue=STRING|"whiteVariable"

[Actions\Action4]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""COLORMATCHEDb"" with value ""beigeVariable"""
Params=FOLDER

[Actions\Action4\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"COLORMATCHEDb"
varvalue=STRING|"beigeVariable"

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

[Actions\Action5\Params]
color1=STRING|"{colorWhite}"
color2=STRING|"$00FFFFFF"
tolerance=STRING|"0"
variable=STRING|"ColorMatcheda"

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

[Actions\Action6\Params]
color1=STRING|"{colorBeige}"
color2=STRING|"$00EDF1F2"
tolerance=STRING|"0"
variable=STRING|"ColorMatchedb"

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

[Actions\Action7\Params]
case=STRING|"0"
case#1=STRING|"0"
connection=STRING|"0"
count=STRING|"2"
operator=STRING|"0"
operator#1=STRING|"0"
type=STRING|"3"
type#1=STRING|"3"
value1=STRING|"{ColorMatcheda}"
value1#1=STRING|"{ColorMatchedb}"

[Actions\Action8]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|0
Name=STRING|"Show ""2017 - Point color is white AND beige."""
Params=FOLDER

[Actions\Action8\Params]
icon=STRING|"1"
msg0=STRING|"2017 - Point color is white AND beige."
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action9]
ActionID=STRING|"A_TASKS_START"
Enabled=INTEGER|-1
Name=STRING|"Start Task ""05  AutotelexPRO invullen + Eurotax openen!"""
Params=FOLDER

[Actions\Action9\Params]
parametercount=STRING|"0"
required=STRING|"0"
taskid=STRING|"1990679332"
wait=STRING|"1"


Image
snowseals
 
Posts: 56
Joined: Mon Apr 11, 2016 10:17 am

Re: 3 states: How do use it proper with 2 If , ElseIf statem

Postby Oleg » Thu Sep 30, 2021 2:12 pm

Look at the steps #5 and #6 (color compliance)
I think that you don't need to use exact comparison. Set tolerance to 8 or 4.
Probably the the real color may differ from the specified sometimes.

For example it may happen when you work on local console or through RDP session.
Oleg Yershov
Oleg
Site Admin
 
Posts: 2668
Joined: Thu Jan 01, 1970 1:00 am

Re: 3 states: How do use it proper with 2 If , ElseIf statem

Postby snowseals » Thu Sep 30, 2021 4:24 pm

Interesting.
I will set both to 8 tolerance to see if it won't occur this way.

NOTE:
I'm not using Remote Desktop or any other, also its not a laptop (which could change color due battery mode / dim-mode vs. when on electrical socket charger)
snowseals
 
Posts: 56
Joined: Mon Apr 11, 2016 10:17 am

Re: 3 states: How do use it proper with 2 If , ElseIf statem

Postby snowseals » Fri Oct 01, 2021 8:35 pm

I have tried to replicate and even on 8 and 16 tolerance it still happens.
notice how 2017 is run (ok) and the next instance 2020 script (not ok) then after a few attempts 2017 is run again (ok)

https://i.imgur.com/BdDUbFe.mp4
snowseals
 
Posts: 56
Joined: Mon Apr 11, 2016 10:17 am

Re: 3 states: How do use it proper with 2 If , ElseIf statem

Postby Oleg » Sat Oct 02, 2021 8:18 am

I see that you run the task from command line from system menu "start"
Pay attention that this menu is above your target form.
I think that sometimes the task takes a screenshot when menu is on the screen yet. So the task takes incorrect screenshot and get incorrect pixels.
System starts the command line immediately and hides the menu some later.
I got such effect during my testing earlier.

Run this task by HotKey trigger or put some pause at 1-st step of the task
Oleg Yershov
Oleg
Site Admin
 
Posts: 2668
Joined: Thu Jan 01, 1970 1:00 am

Re: 3 states: How do use it proper with 2 If , ElseIf statem

Postby snowseals » Sun Oct 03, 2021 10:27 pm

I think you are right - the black CLI window shows a fraction, which is probably the culprit..
I've now set a DELAY of 200 ms in front, and so far it's solid.

Thanks again Oleg!
Consider it solved. :idea:
snowseals
 
Posts: 56
Joined: Mon Apr 11, 2016 10:17 am


Return to General Discussion

Who is online

Users browsing this forum: Oleg and 6 guests