How to close the iMacros Browser?

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

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
Post Reply
Roy Holzem
Posts: 3
Joined: Mon May 26, 2014 6:18 am

How to close the iMacros Browser?

Post by Roy Holzem » Tue May 27, 2014 10:55 am

Hello,

I need to close the iMacro Browser (the .exe) and TAB CLOSE only closes a TAB,
what options do I have within the macro function (not iimExit())?


If there is no propper function ( I tried to google for it ) i'd go with something like send: ALT F4



Thank you in advance for support
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How to close the iMacros Browser?

Post by chivracq » Tue May 27, 2014 2:00 pm

Roy Holzem wrote:Hello,

I need to close the iMacro Browser (the .exe) and TAB CLOSE only closes a TAB,
what options do I have within the macro function (not iimExit())?

If there is no propper function ( I tried to google for it ) i'd go with something like send: ALT F4

Thank you in advance for support
FCIM...! :mrgreen:

-1- First thought I had is to launch your (Browser and) Script from a Batch File and to issue a 'taskkill' once your Script has finished running. (This should work...)

-2- Second thought was indeed to simulate a Keypress with ALT^F4.
In iMacros for Firefox, you should be able to use the EVENT Mode with one of these Statements:

Code: Select all

EVENT TYPE=KEYPRESS SELECTOR="HTML>BODY" KEY=115 MODIFIERS="alt"

Code: Select all

EVENT TYPE=KEYPRESS SELECTOR=* KEY=115 MODIFIERS="alt"

Code: Select all

EVENT TYPE=KEYPRESS KEY=115 MODIFIERS="alt"
... But they don't work!! :mrgreen:
Even after I checked/modified 'dom.allow_scripts_to_close_windows' to "TRUE" in 'about:config'...

I don't know why, because the following Statements do work fine:

Code: Select all

'Toggle Full Screen (F11):
EVENT TYPE=KEYPRESS KEY=122

Code: Select all

'Browse Open Archives (Alt^m):
EVENT TYPE=KEYPRESS CHAR="m" MODIFIERS="alt"
The EVENT Mode is only available for iMacros for Firefox, maybe it was an option for you to run your Script in FF, or use some Keypress Emulation like explained in the following Thread, though the "ALT" part might have been tricky (I tried a whole list of combinations with "18 AND 115"), but I didn't get it to work anyway...
=> How to simulate a keypress using Javascript

-3- The third thought was to use some JavaScript, and Google took me to this Page:
=> How can I close a browser window without receiving the “Do you want to close this window” prompt?
Several Methods explained, but "window.close()" will only close a Window that was opened by JavaScript...
The Function I retained is:

Code: Select all

this.focus();
self.opener=this;
self.close();
... which I transformed into:

Code: Select all

javascript:this.focus();self.opener=this;self.close()
... which you cannot run in the Address-bar in Firefox anymore since a few Versions, but in the Web Console, and yes!, it worked! One Browser Instance with 1 Tab gets closed or only the current Tab gets closed if you have several Tabs open. Good!

But how can I invoke the Web Console from iMacros? It luckily has a Shortcut (Ctrl^Shift^j) and indeed, using the EVENT Mode again, I manage to launch it and a Paste of that Statement in the Clipboard should do the trick. But I didn't manage to get the Paste to work. I give my Script for Reference, but it didn't work:

Code: Select all

SET !CLIPBOARD "javascript:this.focus(); self.opener=this; self.close()"
PROMPT {{!CLIPBOARD}}
'Launch Firefox Web Console:
EVENT TYPE=KEYPRESS CHAR="k" MODIFIERS="ctrl,shift"
WAIT SECONDS=3
'Paste Clipboard Content:
EVENT TYPE=KEYPRESS CHAR="v" MODIFIERS="ctrl"
'Hit ENTER:
EVENT TYPE=KEYPRESS KEY=13
I didn't try with Tab-Tab-Tab-Tab-Tab... (EDIT: It works, but the number of Tab-Tab-Tab depends on the Page...) or with the Mouse Coordinates to find a way to manage to select (again because it already had the Focus) the correct Field...

-4- Now the fourth thought, which proved to be successful, is simply to use!:

Code: Select all

URL GOTO=javascript:this.focus();self.opener=this;self.close()
If several Tabs are open, only the current Tab is closed, you may need to loop/repeat that Statement a few times if you want to make sure to close the Last Tab (and the Window with it) if you have several Tabs open...
Tested on iMacros v8.8.2 for FF on Pale Moon v24.5.0 (=FF29) on WinXP SP3.
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Roy Holzem
Posts: 3
Joined: Mon May 26, 2014 6:18 am

Re: How to close the iMacros Browser?

Post by Roy Holzem » Wed May 28, 2014 6:25 am

Hello chivracq,

Thank you very much for your propositions, I got it to work with a timed ALT F4.


Impressive response though :idea:


Best regards :)
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How to close the iMacros Browser?

Post by chivracq » Wed May 28, 2014 7:25 am

Roy Holzem wrote:Hello chivracq,

Thank you very much for your propositions, I got it to work with a timed ALT F4.

Impressive response though :idea:

Best regards :)
Okay, but I don't understand what you mean by "a timed ALT F4"... Can you explain? (And post your Script if some Code is required...?)

The 'URL GOTO' Solution is quite powerful btw, I think..., but I've tested it only on Pale Moon (= Firefox), I would be interested to know if it works as well for other Browsers, among them for the iMacros Browser... Could you test that...?
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How to close the iMacros Browser?

Post by chivracq » Mon Jun 16, 2014 2:50 am

Pity you never replied anymore to my last Post... :roll:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How to close the iMacros Browser?

Post by chivracq » Sun Dec 07, 2014 9:05 pm

Other relevant Threads:
- Batch File: Load Firefox, Run Macro(s), Close
- Any way of writing a macro that closes the entire browser?
- Unable to close Firefox (Aug.2016 - Feb.2017) + 'Ctrl^Shift^w' + VM + FF/PM.

(Last Update: 2017-02-04.)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How to close the iMacros Browser?

Post by chivracq » Wed Sep 12, 2018 4:28 pm

chivracq wrote:-4- Now the fourth thought, which proved to be successful, is simply to use!:

Code: Select all

URL GOTO=javascript:this.focus();self.opener=this;self.close()
If several Tabs are open, only the current Tab is closed, you may need to loop/repeat that Statement a few times if you want to make sure to close the Last Tab (and the Window with it) if you have several Tabs open...
Tested on iMacros v8.8.2 for FF on Pale Moon v24.5.0 (=FF29) on WinXP SP3.
Some Update on this Syntax, as my original Post was already from more than 4 years ago, ah-ah...! :shock:

I not funnily at all (as hardly any new Functionality was added to iMacros for FF, on the contrary actually, all later Versions especially v9.0.3 and v10.0.2 were/are very limited (and buggy), compared to v8.8.2 and later v8.9.7 which is OK) still use the same iMacros for FF Version: v8.8.2, ah-ah...!

=> This Syntax to close a Tab (and the Browser Instance if it's the last Tab), and which can easily be used for a "Conditional CLOSE", still works in the following FCI's:
- iMacros for FF v8.8.2, Pale Moon v26.3.3_x32 (=FF47), Win10_x64.
- iMacros for FF v8.9.7, FF v55.0.3_x32, Win10_x64.

It doesn't seem to work anymore in:
- iMacros for FF v10.0.2.1450 'Free', FF v62.0_x64 (Portable), Win10_x64.
(I also tested with v10.0.2.1440 (Beta) + FF v61.0.1_x64 (Portable), same Result...)
=> The Script runs, but it does nothing, no Error...
But hum, I'm running FF62 Portable a bit "out-of-the-Box", I didn't tune its 'about:config' at all, (as I don't use this Browser at all, because of all Limitations with v10.0.2 ('Free'), I had only installed it for the v10.0.2 Beta-Testing Phase), and I think I remember that some "Allow-JavaScript-to-close-Tabs/Windows" Setting was needed..., hum, that could play a role...! :twisted:

=> Yep, found it: 'dom.allow_scripts_to_close_windows' (='default' ='false') => I toggle it to 'true'... :P
And yep indeed, that makes a Difference...! I can close a Tab...! :D

But hum..., it works "half"...! That Line is able to close the current Tab indeed, but the Script then hangs on that Line, 'Pause'/'Resume' does nothing, I can only 'Stop' the Macro. (I made sure the "next" Tab is opened on some "normal" 'http'/'https' Web-Page, no 'about:xxx' whatever Pages which are now a big pain in the ass with v10.0.2... :roll: )

But if the "Purpose" is to close the Browser Instance, so if there is only 1 Tab in that FF Instance (after a 'TAB CLOSEALLOTHERS' for example), then it still "does the job"...! (and the Window is closed.) 8)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Post Reply