Hi,
I have created a flow that uses the control UI action.
It basically clicks a button, waits three seconds for the next screen to load and then clicks another button.
It all works just fine, but I had to set the wait time to 3 seconds to make sure that the next screen has loaded before automagic tries to click the next button (defined by the name of the button, not by coordinates).
The loading time varies between 1-3 seconds though, so I was wondering if I could get automagic to try clicking the button every 200ms until successfully clicked, for a maximum time of 5 seconds, to make sure that the script does not run infinitely if something goes wrong.
Is there any way of achieving this?
Thanks in advance
Jan
Control UI - wait until clicked
Moderator: Martin
Re: Control UI - wait until clicked
Hi,
The click-function returns a boolean with true when the click succeeds so you could use a loop to click as long as it was not successful with a short sleep within the loop.
Regards,
Martin
The click-function returns a boolean with true when the click succeeds so you could use a loop to click as long as it was not successful with a short sleep within the loop.
Regards,
Martin
Re: Control UI - wait until clicked
Thanks for your reply,
I am not very used to actionscript, but after a bit of reading and experimenting I managed to get to this bit of code:
clicked = click("Name of button");
while (not clicked)
{ sleep (200);
clicked = click("Name of button");}
The code works fine and keeps trying to click that button until it was successful. I would like to make it stop after a set amount of tries or seconds though, as I don´t want it to run for too long, should it not be able to hit the button for whatever reason. Any idea on how I could achieve that?
I am not very used to actionscript, but after a bit of reading and experimenting I managed to get to this bit of code:
clicked = click("Name of button");
while (not clicked)
{ sleep (200);
clicked = click("Name of button");}
The code works fine and keeps trying to click that button until it was successful. I would like to make it stop after a set amount of tries or seconds though, as I don´t want it to run for too long, should it not be able to hit the button for whatever reason. Any idea on how I could achieve that?
Re: Control UI - wait until clicked
I got there in the end, so this is my solution:
a = 0;
clicked = click("NameOfButton");
while (not clicked)
{sleep (200);
clicked = click("NameOfButton");
a = a+1;
if (a > 15)
{break;} }
This script will try to click the button every 200ms, until successfully clicked. It will break the loop after 15 unsuccessful attempts which equals 3 seconds (15x0.2 seconds).
Maybe it´ll help someone else with a similar problem. There might be a better/easier way to achieve the same result, but it works for me.
a = 0;
clicked = click("NameOfButton");
while (not clicked)
{sleep (200);
clicked = click("NameOfButton");
a = a+1;
if (a > 15)
{break;} }
This script will try to click the button every 200ms, until successfully clicked. It will break the loop after 15 unsuccessful attempts which equals 3 seconds (15x0.2 seconds).
Maybe it´ll help someone else with a similar problem. There might be a better/easier way to achieve the same result, but it works for me.