Legalien wrote: ↑Wed Apr 01, 2020 6:53 pm
I am looking for a way to pause an iMacro script until the current tab is manually closed, at which point I want the iMacro to continue working (without me having to click continue).
So here is the scenario.
iMacro starts and loads page
iMacro jumps to Tab 2
iMacro pauses after 60 seconds
After some time tab 2 is closed by user
iMacro continues to work on Tab 1
The reason I need this, well, there is this website where Tab 1 will "expire" some seconds after Tab 2 is closed. And the amount of time I need to spend on Tab 2 is always different, so having a set amount of seconds that iMacro stay on Tab 2 creates problems for me.
Simply put, I need a command so that my script:
Load page
Click go Tab 2
Wait Seconds=60
PAUSE until tab 2 is closed...
...at some point the user manually closes tab 2...
iMacro script continues to work automatically as soon as tab 2 is closed.
Not sure if possible. Is it?
Thanks
For the scenario that you described above, I think a simple loop can help you in JavaScript. Here is something that you can do: -
1. Jump to Tag 2
2. Use 15 seconds as compulsory wait using WAIT SECONDS=15
3. Then, keep checking the URL of the current tab every half a second.
4. If the URL of the current tab changes, it means the user has closed the tab.
I am sharing the code that will "pause" the script until the user manually closes the tab.
Code: Select all
var tabURL = window.location.toString();
while(1)
{
iimPlayCode("WAIT SECONDS=0.5");
if(tabURL!=window.location.toString())
break;
}
Another possible solution that is possible if Tab 2 doesn't have JavaScript is to simply do an alert() so that the execution freezes. Then, the user can dismiss the popup and close the tab. Here is what I mean: -
Code: Select all
alert("Please close the tab");
iimPlayCode("WAIT SECONDS=3");
// Code that runs on Tab 1
I have added a wait of 3 seconds because I assume the user can manually close the tab within 3 seconds.
I assume that you want the closing of the tab to be automated too. I can't seem to find the exact use case. If you can share that, I might be able to help you automate closing the tab automatically too.
I hope it helps
Robust iMacros development with quick turnaround time. Drop an email at "access2content@gmail.com" with your project details.