How to close Firefox with the Process instruction

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
nigelle
Posts: 10
Joined: 23 Oct 2013, 09:58
Location: France

How to close Firefox with the Process instruction

20 Apr 2016, 08:42

Purpose : write a general purpose script that closes all occurrences of Firefox remaining from previous scripts or manual use of Firefox (to achieve a clean start). I don't care loosing data but I don't know which screens are open.

-First trial (WaitClose)

Code: Select all

Process, WaitClose, firefox.exe, 120 ; Process, Cmd, PID-or-Name [, Param3] seconds
NewPID = %ErrorLevel%  ; Save the value immediately since ErrorLevel is often changed.
MsgBox  %NewPID%
According to the help this should have returned 0 and closed Firefox but the result was the same as the pid of the task screen and "firefox.exe" (as written in the task screen) still open.

-Second trial (Exist)

Code: Select all

Process, Exist, firefox.exe ; Process, Cmd, PID-or-Name [, Param3] seconds
NewPID = %ErrorLevel%  ; Save the value immediately since ErrorLevel is often changed.
MsgBox  %NewPID%
The result was the same as the pid of the task screen that is normal.

-Third trial (Exist+WaitClose)

Code: Select all

Process, Exist, firefox.exe ; Process, Cmd, PID-or-Name [, Param3] seconds
NewPID = %ErrorLevel%  ; Save the value immediately since ErrorLevel is often changed.
MsgBox  %NewPID%
Process, WaitClose, %NewPID%, 120
if ErrorLevel ; The PID still exists.
    MsgBox The process did not close within 120 seconds.
According to the help this should have closed Firefox but the first message was the same as the pid of the task screen and Firefox still open.

-Fourth trial (Exist+Close)

Code: Select all

Process, Exist, firefox.exe ; Process, Cmd, PID-or-Name [, Param3] seconds
NewPID = %ErrorLevel%  ; Save the value immediately since ErrorLevel is often changed.
Process, Close, %NewPID%
Firefox still open.

Where is the problem ? Misunderstanding of help ? Error in coding ? Bug ?
I run Windows 10 and Autohotkey Version v1.1.19.02

I may perhaps, as in :
https://autohotkey.com/boards/viewtopic.php?f=5&t=6455
use

Code: Select all

GroupAdd MultiClose, ahk_class MozillaWindowClass
WinClose, ahk_group MultiClose
but it just close the screens that do not need a confirmation to close ! So I am not sure to close Firefox if one of this few vicious screens exist...
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: How to close Firefox with the Process instruction

20 Apr 2016, 12:26

Try this.

Code: Select all

run, taskkill /F /IM firefox.exe /T
Please excuse my spelling I am dyslexic.
nigelle
Posts: 10
Joined: 23 Oct 2013, 09:58
Location: France

Re: How to close Firefox with the Process instruction

20 Apr 2016, 17:07

It has closed Firefox but when I open Firefox later all the screens are re-opened.
User avatar
Capn Odin
Posts: 1352
Joined: 23 Feb 2016, 19:45
Location: Denmark
Contact:

Re: How to close Firefox with the Process instruction

20 Apr 2016, 19:01

If you mean the session is restored then try deleting the "sessionstore.js" and is backups in "AppData\Roaming\Mozilla\Firefox\Profiles".
Please excuse my spelling I am dyslexic.
SpecialGuest

Re: How to close Firefox with the Process instruction

20 Apr 2016, 19:22

..or disable Session Restore in the Firefox Settings.
nigelle
Posts: 10
Joined: 23 Oct 2013, 09:58
Location: France

Re: How to close Firefox with the Process instruction

26 Apr 2016, 07:10

Apparently the problem of previous screens comes from session restore :
I have set to false in about:config (of Firefox)
browser.sessionstore.resume_from_crash
and they disappeared...
It seems that Firefox thinks that is has crashed when it is closed by means external to itself.

So the post is half solved : I can do what I wish but I don't know why I cannot do it with AHK that seems able to do it.

CAN SOMEBODY CLARIFY WHY I CANNOT CLOSE A PROCESS AS FIREFOX WITH AHK ?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: balawi28 and 225 guests