Pause iMacro until tab is closed - resume script automatically

Discussions and Tech Support specific to the iMacros Firefox add-on.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Legalien
Posts: 100
Joined: Mon Feb 15, 2016 6:47 pm
Contact:

Re: Pause iMacro until tab is closed - resume script automatically

Post by Legalien » Mon Apr 06, 2020 5:17 pm

I just spent a few more hours trying to solve it, but no luck. I eventually managed to insert a frame on Tab 1 and have it be Frame 1. I did it by using Inspect Element and adding a frame directly into the Body, and then editing the code that frame loads to include my text, and that worked.

But I don't know how to make it permanent, plus it's super ugly, and it requires a loading of another frame, so more loading on the page. I am not happy with that solution.

I initially only did the tagging on Tab 1, but it's more effective if I do it on Tab 2. My script is made more efficient by tagging on Tab 2.

So this is the HTML:

Code: Select all

<div id="80">Click for <span id="counter">0</span>/
		5 minutes
        </div>
I got lucky when I found a way to tag it, as I mentioned in my previous post. I tag like this:

Code: Select all

FRAME F=1
TAG POS=1 TYPE=SPAN ATTR=TXT:0
But do you think it could be tagged without using the FRAME bit? I tried all the recording modes but unfortunately they all come with FRAME F=1.
Buy Social Media Services - https://Socialesale.com
chivracq
Posts: 9378
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Pause iMacro until tab is closed - resume script automatically

Post by chivracq » Mon Apr 06, 2020 5:36 pm

Legalien wrote:
Mon Apr 06, 2020 5:17 pm
I just spent a few more hours trying to solve it, but no luck. I eventually managed to insert a frame on Tab 1 and have it be Frame 1. I did it by using Inspect Element and adding a frame directly into the Body, and then editing the code that frame loads to include my text, and that worked.

But I don't know how to make it permanent, plus it's super ugly, and it requires a loading of another frame, so more loading on the page. I am not happy with that solution.

I initially only did the tagging on Tab 1, but it's more effective if I do it on Tab 2. My script is made more efficient by tagging on Tab 2.

So this is the HTML:

Code: Select all

<div id="80">Click for <span id="counter">0</span>/
		5 minutes
        </div>
I got lucky when I found a way to tag it, as I mentioned in my previous post. I tag like this:

Code: Select all

FRAME F=1
TAG POS=1 TYPE=SPAN ATTR=TXT:0
But do you think it could be tagged without using the FRAME bit? I tried all the recording modes but unfortunately they all come with FRAME F=1.

Well, no...!, if it's in a 'FRAME', then iMacros needs the 'FRAME' Statement, or it will definitely not find it...

But the Content of a Frame usually has its own URL, if you can identify it, maybe you can try to load that Frame directly in 'TAB_2' (or 'TAB_3')...

Oh yeah...!, and I had mentioned that I found your "TAG POS=1 TYPE=SPAN ATTR=TXT:0" (for both Tabs, with or without the 'FRAME') not very "safe", and that your Script could possibly easily be "fooled" if there was any other 'SPAN' Element with a "0" as Content...

A few other "Possibilities"...:

Code: Select all

TAG POS=1 TYPE=SPAN ATTR=ID:Counter&&TXT:0

Code: Select all

TAG POS=1 TYPE=DIV ATTR=ID:80&&TXT:Click<SP>for*0*/*5<SP>minutes*

Code: Select all

TAG POS=1 TYPE=SPAN ATTR=ID:Counter&&TXT:0
TAG POS=R-1 TYPE=DIV ATTR=ID:80&&TXT:Click<SP>for*5<SP>minutes*
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
Legalien
Posts: 100
Joined: Mon Feb 15, 2016 6:47 pm
Contact:

Re: Pause iMacro until tab is closed - resume script automatically

Post by Legalien » Mon Apr 06, 2020 5:56 pm

I checked for the URL, but I'm sure that URL changes on every page reload.

The pages are pretty static, there are no other SPAN elements that would just appear.

I tried the other 2 possibilities you mentioned, but they didn't work.

Okay, well, I tried.

Unfortunately I don't see a way to get this done. So I'll have to go back to my initial plan to only use Timeout Step on Tab 1, and what needs to be done on Tab 2 I'll hire someone to create a Firefox Extension to do it.

It sucks, but I tried really hard and didn't manage.
Buy Social Media Services - https://Socialesale.com
access2vivek
Posts: 63
Joined: Wed Dec 20, 2017 10:00 am
Location: New Delhi, India
Contact:

Re: Pause iMacro until tab is closed - resume script automatically

Post by access2vivek » Sun Jun 14, 2020 6:33 am

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.
Legalien
Posts: 100
Joined: Mon Feb 15, 2016 6:47 pm
Contact:

Re: Pause iMacro until tab is closed - resume script automatically

Post by Legalien » Sun Jun 14, 2020 11:33 am

Thanks for the reply. But I don't use Javascript :)

I fixed it like I said in my last post.
Buy Social Media Services - https://Socialesale.com
Post Reply