Page 1 of 1

Wait till website is finished loading, then proceed - how?

Posted: Sat Apr 16, 2016 10:15 am
by snowseals
I've made a marco using the recorder of Robotask, to automatically open Google Chrome, going to a certain website, where it needs to hit on a download-button.
This all works fine, yet, the loading time of the website differs.
This way the website sometimes isnt done loading, so the download button havent appeared yet.

Ofcourse, I can set the delay between hitting the download-button to like 10 secs, but isnt there a way to let's say:
"Wait till website is finished loading"?

Re: Wait till website is finished loading, then proceed - ho

Posted: Mon Apr 18, 2016 6:47 am
by Oleg
... I can set the delay between hitting the download-button to like 10 secs...
If you use the external web browser then this is the only way

Re: Wait till website is finished loading, then proceed - ho

Posted: Tue May 17, 2016 11:56 am
by snowseals
How about the the usage of Screen Pixel compliance?

For instance,
The website is loading and at a sudden moment, the Download knob appears (which has a different color than when the knob wasnt showing before).

I could make an if/else solution, like, if color at specific location is #grey do nothing, else (the button is blue and showing) run the script further from here?

Re: Wait till website is finished loading, then proceed - ho

Posted: Fri May 20, 2016 1:38 pm
by snowseals
*bump*

Re: Wait till website is finished loading, then proceed - ho

Posted: Tue May 24, 2016 2:28 pm
by Rukbunker
First of all make sure the website is always opening at the same resolution and viewing percentage since the script will watch exactly one pixel, it comes very precise.

First I have created a test task in which I will constantly monitor the HEX color code of a specific pixel.

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|161709911
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task5"
Hide=INTEGER|0
ID=INTEGER|1304254708
LocalVariables=STRING|"Kleur=$000000"
LogOnAsUser=INTEGER|1
Name=STRING|"[TEST] - Color Detector"
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

[Actions\Action1]
ActionID=STRING|"A_LOOP_WHILE"
Enabled=INTEGER|-1
Name=STRING|"While loop"
Params=FOLDER

[Actions\Action1\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"1"
type=STRING|"0"
value1=STRING|"{Kleur}"
value2=STRING|"$DCC8D8"

[Actions\Action2]
ActionID=STRING|"A_ROBOTASK_ALERT"
Enabled=INTEGER|-1
Name=STRING|"Show Notification"
Params=FOLDER

[Actions\Action2\Params]
defh=STRING|"1"
defw=STRING|"1"
duration=STRING|"2"
height=STRING|"76"
icon=STRING|"1"
kind=STRING|"0"
message=STRING|"{Kleur}"
position=STRING|"3"
title=STRING|"The color HEX is"
width=STRING|"330"

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

[Actions\Action3\Params]
variable=STRING|"kleur"
x=STRING|"271"
y=STRING|"12"

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

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

[Actions\Action5]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"

It will display the HEX code every x seconds in the right down corner. When you have the right HEX code, add this part to your "main" task and change the HEX decimal there.
Here is a example code from one of my tasks.

Code: Select all

;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
 
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|287542956
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task231"
Hide=INTEGER|0
ID=INTEGER|676856636
LocalVariables=STRING|"FileName=M:\FINANCE\Downloads\Balance.txt"
LogOnAsUser=INTEGER|1
Name=STRING|"[AX] [FINANCE] 06A - Financial Statements (BS Local)"
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
Action15=FOLDER
Action16=FOLDER
Action17=FOLDER
Action18=FOLDER
Action19=FOLDER
Action2=FOLDER
Action20=FOLDER
Action21=FOLDER
Action22=FOLDER
Action23=FOLDER
Action24=FOLDER
Action25=FOLDER
Action26=FOLDER
Action27=FOLDER
Action28=FOLDER
Action29=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER

[Actions\Action1]
ActionID=STRING|"A_ROBOTASK_ALERT"
Enabled=INTEGER|-1
Name=STRING|"Show Notification"
Params=FOLDER

[Actions\Action1\Params]
defh=STRING|"1"
defw=STRING|"1"
duration=STRING|"2"
height=STRING|"76"
icon=STRING|"3"
kind=STRING|"0"
message=STRING|"{TaskName}"
position=STRING|"3"
title=STRING|"--START--"
width=STRING|"330"

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

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

[Actions\Action11]
ActionID=STRING|"A_GENERAL_SENDKEYS"
Enabled=INTEGER|-1
Name=STRING|"Send keys to active window"
Params=FOLDER

[Actions\Action11\Params]
currentwindow=STRING|"1"
fixedwindow=STRING|"0"
keylayout=STRING|"0"
keys=STRING|"""{TAB}{DELAY 100}{TAB}{DELAY 100}{TAB}{DELAY 100}"""
pause=STRING|"20"
release=STRING|"0"
sendkind=STRING|"0"
wincaption=STRING|"Notepad"

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

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

[Actions\Action13]
ActionID=STRING|"A_GENERAL_SENDKEYS"
Enabled=INTEGER|-1
Name=STRING|"Fill in the variable (Step 2)"
Params=FOLDER

[Actions\Action13\Params]
currentwindow=STRING|"1"
fixedwindow=STRING|"0"
keylayout=STRING|"0"
keys=STRING|"{LASTDATE}"
pause=STRING|"20"
release=STRING|"0"
sendkind=STRING|"0"
wincaption=STRING|"Notepad"

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

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

[Actions\Action15]
ActionID=STRING|"A_GENERAL_SENDKEYS"
Enabled=INTEGER|-1
Name=STRING|"Goto Options (Alt+I)"
Params=FOLDER

[Actions\Action15\Params]
currentwindow=STRING|"1"
fixedwindow=STRING|"0"
keylayout=STRING|"0"
keys=STRING|"%(I)"
pause=STRING|"20"
release=STRING|"0"
sendkind=STRING|"0"
wincaption=STRING|"Notepad"

[Actions\Action16]
ActionID=STRING|"A_GENERAL_SENDKEYS"
Enabled=INTEGER|-1
Name=STRING|"Goto filepath (TAB)"
Params=FOLDER

[Actions\Action16\Params]
currentwindow=STRING|"1"
fixedwindow=STRING|"0"
keylayout=STRING|"0"
keys=STRING|"""{TAB}{DELAY 100}"""
pause=STRING|"20"
release=STRING|"0"
sendkind=STRING|"0"
wincaption=STRING|"Notepad"

[Actions\Action17]
ActionID=STRING|"A_GENERAL_SENDKEYS"
Enabled=INTEGER|-1
Name=STRING|"Paste into field"
Params=FOLDER

[Actions\Action17\Params]
currentwindow=STRING|"1"
fixedwindow=STRING|"0"
keylayout=STRING|"0"
keys=STRING|"{FileName}"
pause=STRING|"20"
release=STRING|"0"
sendkind=STRING|"0"
wincaption=STRING|"Notepad"

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

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

[Actions\Action19]
ActionID=STRING|"A_GENERAL_SENDKEYS"
Enabled=INTEGER|-1
Name=STRING|"OK (Alt+O), close options"
Params=FOLDER

[Actions\Action19\Params]
currentwindow=STRING|"1"
fixedwindow=STRING|"0"
keylayout=STRING|"0"
keys=STRING|"%(O)"
pause=STRING|"20"
release=STRING|"0"
sendkind=STRING|"0"
wincaption=STRING|"Notepad"

[Actions\Action2]
ActionID=STRING|"A_TASKS_START"
Enabled=INTEGER|-1
Name=STRING|"[AX] [FINANCE] 06D - Financial Statements (Defining workdays)"
Params=FOLDER

[Actions\Action2\Params]
parametercount=STRING|"0"
required=STRING|"0"
taskid=STRING|"-1403921704"
wait=STRING|"1"

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

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

[Actions\Action21]
ActionID=STRING|"A_GENERAL_SENDKEYS"
Enabled=INTEGER|-1
Name=STRING|"OK (Alt+O), execute"
Params=FOLDER

[Actions\Action21\Params]
currentwindow=STRING|"1"
fixedwindow=STRING|"0"
keylayout=STRING|"0"
keys=STRING|"%(O)"
pause=STRING|"20"
release=STRING|"0"
sendkind=STRING|"0"
wincaption=STRING|"Notepad"

[Actions\Action22]
ActionID=STRING|"A_LOOP_WHILE"
Enabled=INTEGER|-1
Name=STRING|"While loop"
Params=FOLDER

[Actions\Action22\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"1"
type=STRING|"0"
value1=STRING|"{Kleur}"
value2=STRING|"$A54117"

[Actions\Action23]
ActionID=STRING|"A_ROBOTASK_ALERT"
Enabled=INTEGER|-1
Name=STRING|"Show Notification"
Params=FOLDER

[Actions\Action23\Params]
defh=STRING|"1"
defw=STRING|"1"
duration=STRING|"2"
height=STRING|"76"
icon=STRING|"1"
kind=STRING|"0"
position=STRING|"3"
title=STRING|"Waiting for Financial Export..."
width=STRING|"330"

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

[Actions\Action24\Params]
variable=STRING|"kleur"
x=STRING|"489"
y=STRING|"490"

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

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

[Actions\Action26]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"

[Actions\Action27]
ActionID=STRING|"A_ROBOTASK_ALERT"
Enabled=INTEGER|-1
Name=STRING|"Show Notification"
Params=FOLDER

[Actions\Action27\Params]
defh=STRING|"1"
defw=STRING|"1"
duration=STRING|"2"
height=STRING|"76"
icon=STRING|"0"
kind=STRING|"0"
position=STRING|"3"
title=STRING|"Financial Export is finished!"
width=STRING|"330"

[Actions\Action28]
ActionID=STRING|"A_GENERAL_SENDKEYS"
Enabled=INTEGER|-1
Name=STRING|"Conform overwrite (Alt+Y)"
Params=FOLDER

[Actions\Action28\Params]
currentwindow=STRING|"1"
fixedwindow=STRING|"0"
keylayout=STRING|"0"
keys=STRING|"%(Y)"
pause=STRING|"20"
release=STRING|"0"
sendkind=STRING|"0"
wincaption=STRING|"Notepad"

[Actions\Action29]
ActionID=STRING|"A_ROBOTASK_ALERT"
Enabled=INTEGER|-1
Name=STRING|"Show Notification"
Params=FOLDER

[Actions\Action29\Params]
defh=STRING|"1"
defw=STRING|"1"
duration=STRING|"2"
height=STRING|"76"
icon=STRING|"3"
kind=STRING|"0"
message=STRING|"{Taskname}"
position=STRING|"3"
title=STRING|"--FINISH--"
width=STRING|"330"

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

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

[Actions\Action4]
ActionID=STRING|"A_MOUSE_MOVE"
Enabled=INTEGER|-1
Name=STRING|"Move"
Params=FOLDER

[Actions\Action4\Params]
dx=STRING|"84"
dy=STRING|"195"
mode=STRING|"0"

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

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

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

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

[Actions\Action7]
ActionID=STRING|"A_CLIPBOARD_PUT"
Enabled=INTEGER|-1
Name=STRING|"BS local to Clipboard"
Params=FOLDER

[Actions\Action7\Params]
line0=STRING|"BS local"
linecount=STRING|"1"
sourcetext=STRING|"1"

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

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

[Actions\Action9]
ActionID=STRING|"A_GENERAL_SENDKEYS"
Enabled=INTEGER|-1
Name=STRING|"Paste into field"
Params=FOLDER

[Actions\Action9\Params]
currentwindow=STRING|"1"
fixedwindow=STRING|"0"
keylayout=STRING|"0"
keys=STRING|"^(V)"
pause=STRING|"20"
release=STRING|"0"
sendkind=STRING|"0"
wincaption=STRING|"Notepad"

Good luck!

Re: Wait till website is finished loading, then proceed - ho

Posted: Tue May 24, 2016 3:18 pm
by Oleg
Good examples

Some notes:
  • - you can compare colors as numbers. But you have to initiate the variable kleur to 0 (for example) before the loop;
    - you can use Color Compliance action to compare the color with some etalon. This action allows the inexact coincidence of colors.

Re: Wait till website is finished loading, then proceed - ho

Posted: Tue May 24, 2016 11:00 pm
by snowseals
omg, it's brilliant! :shock:
esp. with the usage of that loop-statement.
I cant thank you enough Rukbunker 8-)

Re: Wait till website is finished loading, then proceed - ho

Posted: Wed May 25, 2016 2:58 pm
by Rukbunker
Have fun with it!

Veel plezier ermee.

Re: Wait till website is finished loading, then proceed - ho

Posted: Wed May 25, 2016 3:11 pm
by Oleg
I could make an if/else solution, like, if color at specific location is #grey do nothing, else (the button is blue and showing) run the script further from here?
I thought that you already found this solution...

Re: Wait till website is finished loading, then proceed - ho

Posted: Wed May 25, 2016 3:14 pm
by Oleg
with the usage of that loop-statement.
We'll add action like "Wait for pixel" in the next release.
It will replace the waiting in the loop.