Page 1 of 1

How to close the iMacros Browser?

Posted: Tue May 27, 2014 3:55 am
by Roy Holzem
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

Re: How to close the iMacros Browser?

Posted: Tue May 27, 2014 7:00 am
by chivracq
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.

Re: How to close the iMacros Browser?

Posted: Tue May 27, 2014 11:25 pm
by Roy Holzem
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 :)

Re: How to close the iMacros Browser?

Posted: Wed May 28, 2014 12:25 am
by chivracq
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...?

Re: How to close the iMacros Browser?

Posted: Sun Jun 15, 2014 7:50 pm
by chivracq
Pity you never replied anymore to my last Post... :roll:

Re: How to close the iMacros Browser?

Posted: Sun Dec 07, 2014 2:05 pm
by chivracq
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.)