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:

Pause iMacro until tab is closed - resume script automatically

Post by Legalien » Wed Apr 01, 2020 6:53 pm

Firefox 55.0.2
iMacros 8.9.7
Windows 10

---

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
Buy Social Media Services - https://Socialesale.com
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 » Wed Apr 01, 2020 7:12 pm

Actually, it's funny, but iMacros already offer this functionality... as a bug :lol:

If a page loads and say Timeout is 30 seconds, but the page doesn't finish loading in those 30 seconds, iMacros will freeze on the next step and stay there frozen.

The second I close that tab, iMacro will keep working.

How do I force this behavior on purpose?
Buy Social Media Services - https://Socialesale.com
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 » Fri Apr 03, 2020 7:13 pm

Anyone here?
Buy Social Media Services - https://Socialesale.com
chivracq
Posts: 9374
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

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

Post by chivracq » Fri Apr 03, 2020 11:29 pm

Legalien wrote:
Wed Apr 01, 2020 6:53 pm

Code: Select all

Firefox 55.0.2
iMacros 8.9.7
Windows 10
---

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
Legalien wrote:
Wed Apr 01, 2020 7:12 pm
Actually, it's funny, but iMacros already offer this functionality... as a bug :lol:

If a page loads and say Timeout is 30 seconds, but the page doesn't finish loading in those 30 seconds, iMacros will freeze on the next step and stay there frozen.

The second I close that tab, iMacro will keep working.

How do I force this behavior on purpose?
Legalien wrote:
Fri Apr 03, 2020 7:13 pm
Anyone here?

Yeah, well, you keep opening your Threads in the 'iMacros for FF' Sub-Forum while your Threads have nothing specific to FF only or you need to mention in which other FCI(s) or which previous Version you've tested, and I don't help for Threads opened in the "wrong" Sub-Forum, especially if I've already asked to select the "correct" Forum... :roll:

>>>

Hum, I don't know what Bug you are talking about, the only "Freeze" Bug I think I know in v8.9.7 for FF is when doing a 'MOUSEMOVE' if the 'SELECTOR' is not present on the Page, but I've provided a Workaround, and it doesn't correspond with your "If a page loads and say Timeout is 30 seconds, but the page doesn't finish loading in those 30 seconds"..., no Script posted to reproduce, so I can't see what Settings you are using, and the Error Page might be specific to this Site, but '!ERRORIGNORE' should be the "Solution" I would think...

And I had never tried/tested with closing the Tab in the Case of the Freeze on a 'MOUSEMOVE', I just did it, and in both v8.8.2 + v8.9.7 for FF, it doesn't help... :(

>>>

But OK, concerning your Scenario, tag some Element that only exists on 'TAB_1' with "!TIMEOUT_STEP=60", and that should do the Trick, I would think... :idea:
Or same Principle, tag some Element on 'TAB_2' that will only appear after you've done your Action(s) on this 'TAB_2', and let your Script close (conditionally maybe) this 'TAB_2'... :idea:
- (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 » Sat Apr 04, 2020 11:36 am

I post in iMacros for Firefox because I am using iMacros for Firefox. I mean, it makes sense I post here. I know you're a stickler for rules, but come on man. Where else would I post? Come on maan :)

---

Regarding the problem.

I often have an issue where iMacro will freeze on "Frame F=" command. That's why I have an AutoHotKey script which... if a browser is stuck on the same page for over 30 minutes, the AHK script goes and clicks Stop, and then clicks Play, in order to restart the script.

I think it happens when the Timeout I set expires but the page has not fully loaded yet, and then the next step is "FRAME F=" command, and then the script freezes. However, if I close the tab where the script froze on, then the script keeps working normally.

---

About the solution. If I understand it correctly, tagging something on Tab 2 and having iMacros close the tab after that something appears, that would work. However sometimes that something never appears, in which case iMacros will just sit there waiting for something that will never appear. So it won't work.

Isn't there a way for me to have the iMacro script freeze when it gets to Tab 2, and stay frozen until Tab 2 is closed? That's all I really need.

Thanks man

---

EDIT: Actually come to think of it, Tagging an element and having iMacros wait for it to appear will freeze the script, but then if that tab is closed iMacros may simply skip (Errorignore) that step and keep working. So this may be a solution.

I need to test it to see how it behaves, but I actually don't know how to tag elements. I am googling now, I will report if I figure it out. If you see this and could tell me how to do it, please do.
Buy Social Media Services - https://Socialesale.com
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 » Sat Apr 04, 2020 11:53 am

Well, no it won't work. Tagging an element will either make iMacros select it and continue, or skip it and continue (or stop working, depending if errorignore is present).

So I'm back to square one...

Isn't there a way for me to have the iMacro script freeze when it gets to Tab 2, and stay frozen until Tab 2 is closed? That's all I really need.
Buy Social Media Services - https://Socialesale.com
chivracq
Posts: 9374
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

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

Post by chivracq » Sun Apr 05, 2020 12:48 pm

Legalien wrote:
Sat Apr 04, 2020 11:36 am
I post in iMacros for Firefox because I am using iMacros for Firefox. I mean, it makes sense I post here. I know you're a stickler for rules, but come on man. Where else would I post? Come on maan :)

Yeah, well, nope..., "I post in iMacros for Firefox because I am using iMacros for Firefox" doesn't make sense to me, the FF Sub-Forum is for '.js' Scripts and Threads specific to FF only, Bug / related to FF-Profiles / etc..., while the Behaviour/Functionality that you want in all your Threads is Generic to all Browsers, and I'm a "Stickler" because I care for Quality, it's already "hard enough" to try to "educate" New Users, I would think that "older" Users know how to use the Forum "correctly"... :?

And I'm the most active Helper, Users who don't want to "play with my Rules", well, then, fair enough, I stop answering their Threads at some point... :|

>>>
Legalien wrote:
Sat Apr 04, 2020 11:36 am
Regarding the problem.

I often have an issue where iMacro will freeze on "Frame F=" command. That's why I have an AutoHotKey script which... if a browser is stuck on the same page for over 30 minutes, the AHK script goes and clicks Stop, and then clicks Play, in order to restart the script.

I think it happens when the Timeout I set expires but the page has not fully loaded yet, and then the next step is "FRAME F=" command, and then the script freezes. However, if I close the tab where the script froze on, then the script keeps working normally.

Hum, Okay..., I'm a bit "surprised"... I also have quite some 'FRAME' Commands in my Scripts, and I have a very shitty Connection, unreliable + gets broken + very slow, it happens very-very regularly that the Page(s) or only part of the Frames manage to load at all/correctly, and my Scripts never freeze... But I'm always on a same Site, so it could be specific to your Site...

Frames Freezing was on the other hand a big/Blocking Pb in one of the first Beta Versions for v10.0.2 for FF, but it finally got a bit solved in some later Beta Release(s), and I was using my very same Script that I use myself (with v8.8.2 + v8.9.7 for FF) which thus was freezing in v10.0.2 but never in the 2 Versions i use myself...

A possible Workaround could actually be the same one I use for the 'MOUSEMOVE'... => Applied to "FRAME F=0" that will always exist... :idea:

Hum..., and stg I never "really" investigated, is indeed how Frames react/behave with iMacros, and if the '!TIMEOUT_PAGE' Setting gets "re-sub-applied" to Frames, and what happens on Sites where you might have Frames in Frames, etc... On the Site where I use them (I have to...!), I've also completely tuned/tweaked my Browsers (PM v26.3.3 and FF v55.0.3) with Script Blockers, so those Pages and Frames are already pretty "clean" from any 3rd Party Scripts... That could play a Role for iMacros, and in your Case, I don't know...

>>>
Legalien wrote:
Sat Apr 04, 2020 11:36 am
About the solution. If I understand it correctly, tagging something on Tab 2 and having iMacros close the tab after that something appears, that would work. However sometimes that something never appears, in which case iMacros will just sit there waiting for something that will never appear. So it won't work.

Isn't there a way for me to have the iMacro script freeze when it gets to Tab 2, and stay frozen until Tab 2 is closed? That's all I really need.

Thanks man

---

EDIT: Actually come to think of it, Tagging an element and having iMacros wait for it to appear will freeze the script, but then if that tab is closed iMacros may simply skip (Errorignore) that step and keep working. So this may be a solution.

I need to test it to see how it behaves, but I actually don't know how to tag elements. I am googling now, I will report if I figure it out. If you see this and could tell me how to do it, please do.

"However sometimes that something never appears" (on 'TAB_2'), then your Script will simply wait for the 60 Sec from the '!TIMEOUT_STEP' before continuing...

"Isn't there a way for me to have the iMacro script freeze when it gets to Tab 2, and stay frozen until Tab 2 is closed?"
=> Yep, that's exactly what I proposed, to tag stg specifically only present on 'TAB_1', with a long '!TIMEOUT_STEP' (=60 also I guess), and you could even combine both...
But if you don't understand the Principle of "Specific" applied to the 'iMacros for FF' Sub-Forum, you may have some Pb's to also apply it to stg that might be "Specific" to 'TAB_1' or 'TAB_2', ah-ah...! :wink:

"but I actually don't know how to tag elements. I am googling now,"
=> Hum, I hope you are not "too serious"... :? , this is the very first Basic Notion you learn with iMacros...! Install the Add-on, start 'Record', and every single Click you do on your Site is a 'TAG'...! 8) 8)

>>>
Legalien wrote:
Sat Apr 04, 2020 11:53 am
Well, no it won't work. Tagging an element will either make iMacros select it and continue, or skip it and continue (or stop working, depending if errorignore is present).

So I'm back to square one...

Isn't there a way for me to have the iMacro script freeze when it gets to Tab 2, and stay frozen until Tab 2 is closed? That's all I really need.

OK, I think I've already answered that part, you just need to try what I mentioned...
Last edited by chivracq on Sun Apr 05, 2020 7:50 pm, edited 1 time in total.
- (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 » Sun Apr 05, 2020 6:48 pm

Well I'll be damned, you did it again! That worked, and it's perfect :)

---

Okay, next time around I'll try to look around to see in which section of the forum I should post. I mean, it's inevitable that you will find something wrong with what I do, but that's unavoidable. It's like death, or taxes, or corona virus, unavoidable :D

But you are right, you are the most active helper, so your rules should be followed (or the forum rules anyway), I respect that.

---

iMacros freezing on frames, it doesn't happen on every run. I can't say for sure what causes it to happen, but whenever a script does freeze it's always on a FRAME line. So it's not a big problem for me, but definitely it happens. Possibly it's because of the website I'm using, or because I tax my internet/computer/cpu to the Max.

---

The confusion about tagging an element, I never really considered it as "tagging." In my mind it's more like "clicking." But I see what you're saying.

That said, I am missing 1 last piece of the puzzle to complete my need. I tried all the recording modes, and I tried searching the forum, but no matter what I tried I can't Tag this one:

Code: Select all

<div id="80">Click for <span id="counter">0</span>/
		5 minutes
        </div>
I can tag div id 80 by recording, but I would like a tag that includes the number 0 there. I feel like it's simple, but I just can't figure it out. Can you help me out?

p.s I could give you the page where this is located, but it requires a login, and I can't expect you to go above and beyond on free help. But I also don't feel it's necessary. I'm pretty sure you'll see that code above and have a solution in your mind instantly.
Buy Social Media Services - https://Socialesale.com
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 Apr 05, 2020 7:16 pm

Legalien wrote:
Sun Apr 05, 2020 6:48 pm
That said, I am missing 1 last piece of the puzzle to complete my need. I tried all the recording modes, and I tried searching the forum, but no matter what I tried I can't Tag this one:

Code: Select all

<div id="80">Click for <span id="counter">0</span>/
		5 minutes
        </div>
I can tag div id 80 by recording, but I would like a tag that includes the number 0 there. I feel like it's simple, but I just can't figure it out. Can you help me out?

p.s I could give you the page where this is located, but it requires a login, and I can't expect you to go above and beyond on free help. But I also don't feel it's necessary. I'm pretty sure you'll see that code above and have a solution in your mind instantly.
This iMacro code tags the HTML code I mentioned above:

Code: Select all

FRAME F=1
TAG POS=1 TYPE=SPAN ATTR=ID:counter
The problem is, that number 0 there changes - <span id="counter">0</span>

And I would like a code that will tag only if 0 is present there.
Buy Social Media Services - https://Socialesale.com
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 Apr 05, 2020 7:26 pm

Ohhhhhhhhhhh pa pow, pa pow, pa pow!!! GOT IT!!!

After 238 hours of reading the forum :D Found it here - https://forum.imacros.net/viewtopic.php?t=28427

This worked:

Code: Select all

FRAME F=1
TAG POS=1 TYPE=SPAN ATTR=TXT:0
I knew it was simple :)
Buy Social Media Services - https://Socialesale.com
chivracq
Posts: 9374
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

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

Post by chivracq » Sun Apr 05, 2020 7:54 pm

Legalien wrote:
Sun Apr 05, 2020 7:26 pm
Ohhhhhhhhhhh pa pow, pa pow, pa pow!!! GOT IT!!!

After 238 hours of reading the forum :D Found it here - https://forum.imacros.net/viewtopic.php?t=28427

This worked:

Code: Select all

FRAME F=1
TAG POS=1 TYPE=SPAN ATTR=TXT:0
I knew it was simple :)

Nope, keep searching, this one is "too dangerous", won't really work, ah-ah...! :twisted:

Hum, actually, the 'FRAME' is helping you, so you might be a bit "lucky" on this Site... :|
Last edited by chivracq on Sun Apr 05, 2020 7:56 pm, edited 1 time in total.
- (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 » Sun Apr 05, 2020 7:55 pm

Okay, I think I figured everything out now.

At first I set a Timeout Step on some text on Tab 1, so that when Tab 2 is closed the script will locate that text and move on.

But then I realized I can make the script even better if I tag some dynamic text on Tab 2. So then if that text is at 0 the script will move on, otherwise it will wait for Timeout Step or for Tab 2 to get closed.

But after I did it I realized that in order for the script to continue from Timeout Step I had to have the same html with 0 on Tab 1. Damn it...

Then I looked for an extension to allow me to inject html on a webpage, and found this - https://addons.mozilla.org/en-US/firefo ... einjector/

It allowed me to insert the html, but then I realized the script will still hang on the Timeout Step because of the FRAME F=1

Code: Select all

SET !TIMEOUT_STEP 100
FRAME F=1
TAG POS=1 TYPE=SPAN ATTR=TXT:0
But I don't know how to insert HTML in a page and add the Frame thing. Meh... :(

But then I figured, try this:

Code: Select all

FRAME F=1
SET !TIMEOUT_STEP 100
TAG POS=1 TYPE=SPAN ATTR=TXT:0
And that worked! Hooray!

One more "issue" I encountered was that Timeout Step would remain for all future steps. I solved it like this:

Code: Select all

FRAME F=1
SET !TIMEOUT_STEP 100
TAG POS=1 TYPE=SPAN ATTR=TXT:0
SET !TIMEOUT_STEP 2
So that's that. Now I just need to restart my browser to see if that Firefox extension remembers what I added to it after restart. If it doesn't I'll look for a different extension or method to add HTML to a webpage. If it does I'll proceed to edit my scripts and then add the extension to all my browsers and take care of everything.

We too cool for school :mrgreen: 8)
Buy Social Media Services - https://Socialesale.com
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 4:13 am

Okay good thing I decided to test this on small scale before rolling it out to all my scripts. I encountered a problem, because of FRAME F=1

On TAB=1 I have no need for FRAME F=1, but on TAB=2 I do need it.

So what happens is if my script runs normally and opens TAB=2 and goes through the steps, it has already selected FRAME=1. And then when it pops back to TAB=1 it only has this to do:

Code: Select all

TAG POS=1 TYPE=SPAN ATTR=TXT:0
However, if the script doesn't go to TAB=2 (and sometimes it doesn't), then it tries to do this on TAB=1

Code: Select all

FRAME F=1
TAG POS=1 TYPE=SPAN ATTR=TXT:0
But TAB=1 doesn't have FRAME F=1 on it, so it doesn't find it, and it doesn't click it! I am 99% sure this is the problem.

I'll look for a way to add FRAME in my HTML. That would be the easiest... well, it's the only solution I can think of. If you see any other solution let me know. I'll report back.
Buy Social Media Services - https://Socialesale.com
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 6:57 am

Ahhhhhhh I tried everything.

On Tab 2 this works:

Code: Select all

FRAME F=1
TAG POS=1 TYPE=SPAN ATTR=TXT:0
On Tab 1 this works:

Code: Select all

TAG POS=1 TYPE=SPAN ATTR=TXT:0
The Frame is causing me a problem.

I tried FRAME F=0, I tried changing the HTML I injected on the page (adding <iframe></iframe> type of code in it), I tried playing with Tab 1 / Tab 2 in the script (thinking maybe it won't work because correct tab not selected by the script). I tried adding the code in HTML using Firefox Inspect Element (thinking maybe if I add it inside the code of the page it will go under Frame 1).

All failed. Don't know how to fix this.
Buy Social Media Services - https://Socialesale.com
chivracq
Posts: 9374
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:01 pm

Legalien wrote:
Mon Apr 06, 2020 6:57 am
Ahhhhhhh I tried everything.

On Tab 2 this works:

Code: Select all

FRAME F=1
TAG POS=1 TYPE=SPAN ATTR=TXT:0
On Tab 1 this works:

Code: Select all

TAG POS=1 TYPE=SPAN ATTR=TXT:0
The Frame is causing me a problem.

I tried FRAME F=0, I tried changing the HTML I injected on the page (adding <iframe></iframe> type of code in it), I tried playing with Tab 1 / Tab 2 in the script (thinking maybe it won't work because correct tab not selected by the script). I tried adding the code in HTML using Firefox Inspect Element (thinking maybe if I add it inside the code of the page it will go under Frame 1).

All failed. Don't know how to fix this.

Yeah, well, then why don't you only do the Check on 'TAB_1'...? And in the worst Case, = if the Page/Site didn't load correctly, the Script will simply wait for 60 Sec...

Or you could do the Check on both Tabs, and the Script will wait Max=120 Sec..., or if you already wait for 60 Sec on 'TAB_2', you can probably shorten the '!TIMEOUT_STEP' on 'TAB_1' to 10 or 20 Sec...
- (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...
Post Reply