topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday March 28, 2024, 4:34 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Last post Author Topic: DONE: Gracefully close Firefox on PC exit  (Read 53037 times)

Curt

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 7,566
    • View Profile
    • Donate to Member
DONE: Gracefully close Firefox on PC exit
« on: March 15, 2008, 07:11 AM »
I will almost "always" forget to close Firefox before I close my XP, so at the next boot it will ask if I want to restore session or not. I find this annoying, because I have Firefox placed in Start > Minimized   for the very reason that I do not want to see it before I need to use it.


IDEA: an app' that will use every XP shutdown / reboot to...
- immediately but gracefully auto-close any Firefox before it is terminated by force!

Please?  :tellme:

I use various programs to shut down XP.

Edited:
Windows will in general close most of the programs in the very same order in which they were started, and because my starting point of Firefox is delayed, so the closing of Firefox will also be delayed, giving enough time for some spy to react and gently close the fox - I would guess.
« Last Edit: March 15, 2008, 07:28 AM by Curt »

nosh

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 1,441
    • View Profile
    • Donate to Member
Re: IDEA: Gracefully close Firefox on PC exit
« Reply #1 on: March 15, 2008, 07:50 AM »
Nice idea. A simple Autohotkey script that closes FF (through its menu system), used in conjunction with something like Xecutor should suffice.

AndyM

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 616
    • View Profile
    • Donate to Member
Re: IDEA: Gracefully close Firefox on PC exit
« Reply #2 on: March 15, 2008, 09:01 AM »
I see in the Tab Mix Plus configuration dialog box there are two yes/no options:  "Use Firefox's built-in Session Restore feature" and "Enable Session Manager" (Tab-Mix's version).

I wonder if unchecking both boxes would stop the unwanted message on restart (if disabling the whole feature was an acceptable trade-off).

For that matter, if Tab Mix Plus can disable the Session remembering, it probably could be disabled via a change in Firefox's about:config settings. Maybe there's even a setting to keep the feature and just disable the "do you want to restore?" dialog.

skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • View Profile
    • 1 Hour Software by skrommel
    • Donate to Member
Re: IDEA: Gracefully close Firefox on PC exit
« Reply #3 on: March 15, 2008, 01:30 PM »
 :) Try CloseToQuit - Close programs before the system shuts down!

Usage: Add the process name, class or a part of the caption of the programs
you want to close to the apps= line. Separate them by commas.
Any spaces or tabs around the delimiting commas are significant,
meaning that they are part of the match string!

Syntax:  apps=[<process name>,<class>,<part of a caption>]

Example: apps=calc.exe,MozillaWindowClass,- Notepad

Skrommel


;CloseToQuit.ahk
;  Close programs before the system shuts down
;  Usage: Add the process name, class or a part of the caption of the programs
;         you want to close to the apps= line. Separate them by commas.
;         Any spaces or tabs around the delimiting commas are significant,
;         meaning that they are part of the match string!
;  Syntax:  apps=[<process name>,<class>,<part of a caption>]
;  Example: apps=calc.exe,MozillaWindowClass,- Notepad
;Skrommel @ 2008


#NoEnv
#SingleInstance,Force
DetectHiddenWindows,On
SetWinDelay,0
SetBatchLines,-1


apps=calc.exe,MozillaWindowClass,- Notepad


DllCall("kernel32.dll\SetProcessShutdownParameters",UInt,0x4FF,UInt,0)
OnMessage(0x11,"WM_QUERYENDSESSION")
Return


WM_QUERYENDSESSION(wParam,lParam)
{
  Global apps

  Gui,+LastFound
  self:=WinExist()
  WinGet,ids,List,,,Program Manager
  Loop,%ids%
  {
    id:=ids%A_Index%
    If id=%self%
      Continue
    WinGet,process,ProcessName,ahk_id %id%
    WinGetClass,class,ahk_id %id%
    WinGetTitle,title,ahk_id %id%
    If process In %apps%
      WinClose,ahk_id %id%
    Else
    If class In %apps%
      WinClose,ahk_id %id%
    Else
    If title Contains %apps%
      WinClose,ahk_id %id%
  }
  ExitApp
}

Curt

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 7,566
    • View Profile
    • Donate to Member
Example for <class>,<part of caption>
« Reply #4 on: March 15, 2008, 02:09 PM »
Thanks, AndyM, but restoring sessions can sometimes be important to me, so I don't think I would want to un-check this option. I would rather go for the script nosh is talking about. Only, I have no idea how to do something like that myself (and I will not purchase $15 Xecutor) - but I do have AutoHotkey installed.

- So I am still requesting some help on this idea, please.

Warning - while you were typing a new reply has been posted.

... studying skrommel's answer...

Syntax:  apps=[<process name>,<class>,<part of a caption>]
Example: apps=calc.exe,MozillaWindowClass,- Notepad

Hmm... I got confused because of the example's content. In my case I expect the program's name must be firefox.exe , but should I also type MozillaWindowClass? And what about the third info, 'part of a caption' - what is that in this connection with firefox? Forgive me for asking such childish questions, but I really mean this thing under Homer van Gogh about me being an IT-analphabetic...

Will someone please  praying2.gif make the example talk about Firefox only?  :tellme:

Other than me knowing nothing I am most grateful for skrommel offering a solution, and for responding so fast.  :up:
« Last Edit: June 28, 2023, 06:41 AM by Curt »

skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • View Profile
    • 1 Hour Software by skrommel
    • Donate to Member
Re: IDEA: Gracefully close Firefox on PC exit
« Reply #5 on: March 15, 2008, 05:24 PM »
 :) You can use CloseToQuit to close a list of apps, with options to close by using the process name, the class name or a part of a window caption.

To close FireFox just use apps=firefox.exe or apps=MozillaWindowClass.

Skrommel

Curt

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 7,566
    • View Profile
    • Donate to Member
Re: IDEA: Gracefully close Firefox on PC exit
« Reply #6 on: March 15, 2008, 08:01 PM »
Many restarts later...:

Something is not all right, because I have not yet been able to make the script work.

Later on I also right-clicked the CloseToQuit.ahk > Compile Script, but when I db'clicked the new exe it said 'exe corrupted'. So something is wrong.

I better ask if this was the right formula: apps=firefox.exe
- no commas, brackets, or anything?
apps.gif
---
I have no idea what such a script should tell, but I am surprised that logonui.exe not is mentioned in the script, because I can see in my taskmanager that logonui is the one handling the XP shutdown. Please forgive me for even saying so.

Curt

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 7,566
    • View Profile
    • Donate to Member
Re: IDEA: Gracefully close Firefox on PC exit
« Reply #7 on: March 29, 2008, 06:12 PM »
bumping...

... I have not yet been able to make the script work.


Maybe I did something else wrong?
- maybe I need the idiot's guide on how to create and to use CloseToQuit ?
 :tellme:

nosh

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 1,441
    • View Profile
    • Donate to Member
Re: IDEA: Gracefully close Firefox on PC exit
« Reply #8 on: March 30, 2008, 03:24 AM »
OK, _total_ AHK novice here but something really simple seems to work for me, the only caveat is you'll have to use it with Xecutor which will intercept the shutdown and run the "script":

IfWinExist,  ahk_class MozillaUIWindowClass
{
    WinActivate 
    Send {Alt}FX
    return
}

This will activate Firefox if it is running and close it through the menu system. I'm using FF 2.x, not sure what the class name would be if you're using v. 3.x. Try running the script manually to see if it closes FF, then restart. You can assign it as a shutdown command to Xecutor if all goes well. 
 

Edit: Xecutor is postcard-ware for non-commercial use.
Clipboard01.jpg
« Last Edit: March 30, 2008, 04:27 AM by nosh »

Curt

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 7,566
    • View Profile
    • Donate to Member
Re: IDEA: Gracefully close Firefox on PC exit
« Reply #9 on: March 30, 2008, 01:26 PM »
Thanks a lot, nosh!  :up:

Havent tried it yet, though, because I am on a big project, and just have taken up Avant...
but I need to ask if your typing was right - winexist - is it "-exist", not "-exit" or "-exits"?
« Last Edit: March 30, 2008, 01:28 PM by Curt »

nosh

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 1,441
    • View Profile
    • Donate to Member
Re: IDEA: Gracefully close Firefox on PC exit
« Reply #10 on: March 30, 2008, 01:31 PM »
Yep. IfWinExist = If the Firefox window exists.
The script doesn't have anything to do with exiting Windows, X-ecutor checks for that.

Curt

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 7,566
    • View Profile
    • Donate to Member
Re: IDEA: Gracefully close Firefox on PC exit
« Reply #11 on: March 30, 2008, 05:27 PM »
My Firefox 2.0.013 didn't respond to IfWinExist.ahk being doubleclicked.

However, I think you should forget about this little project. I am having a hard time to explain to myself why I am installing and running a program with the sole job to close another program I could easily close myself in the first place.

But thanks a lot, nosh, for trying to help me out!  :up:


X-cutor has left the building!

Curt

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 7,566
    • View Profile
    • Donate to Member
Re: IDEA: Gracefully close Firefox on PC exit
« Reply #12 on: March 30, 2008, 05:39 PM »
Re-reading the thread, I realize that I have not told all there might be to tell, but I don't know if it makes any difference that my Firefox always is being minimized to sys-tray (Notification Area), never to the taskbar, and that my sys-tray 'is' PS Tray Factory?

I was just wondering why these scripts couldn't find Firefox's window.

nosh

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 1,441
    • View Profile
    • Donate to Member
Re: IDEA: Gracefully close Firefox on PC exit
« Reply #13 on: March 31, 2008, 01:30 AM »
No problem, Curt. This exact problem had been affecting me too but it was something I'd not really bothered doing anything about so far. I wouldn't know for sure about tray minimizing affecting things, I suspect it may have something to do with the window being hidden. I see skrommel's script has the code
DetectHiddenWindows,On
to check for hidden windows too, maybe that's required here... no need to break your head over it though, unless you really need it.
The script didn't work for me at first coz I had the 'File' menu hidden and the menu shortcut to close Firefox [Alt+F+X] wouldn't work till I unhid it.
« Last Edit: March 31, 2008, 01:41 AM by nosh »

J-Mac

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 2,918
    • View Profile
    • Donate to Member
Re: IDEA: Gracefully close Firefox on PC exit
« Reply #14 on: March 22, 2009, 12:14 PM »
Sorry to activate an older thread but I figured this would be the best place to ask about CloseToQuit.

There are always a couple of programs that do not respond well to the OS call to quit when restarting the computer. One that has suddenly started to give me fits is Surfulater 3: for the past several days it opens with Windows but throws up a dialog stating that it did not close properly the last time and therefore must recover the last saved copy of the DB I use. Perhaps when I restarted those times it just caught Surfulater at a time when it wasn't ready to close for some reason. I have a few apps that are always sitting in the systray and I let them close with Windows.

It doesn't appear that many folks have commented about CloseToQuit here. Is it working OK? Causing any problems otherwise for anyone? Safe to use?

Thanks!

Jim

Curt

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 7,566
    • View Profile
    • Donate to Member
Re: IDEA: Gracefully close Firefox on PC exit
« Reply #15 on: March 23, 2009, 08:35 AM »
I have not had any of the aforementioned problems since I made the swift to Vista and Firefox 3, so I don't have any use for CloseToQuit. Back then, a year ago, I was never able to make it work with both PS Tray Factory and Firefox 2. However, your situation is a little different, so Edited: I dare to recommend you to at least try CloseToQuit. It will certainly not do your setup any harm.
« Last Edit: March 23, 2009, 05:41 PM by Curt »

tomos

  • Charter Member
  • Joined in 2006
  • ***
  • Posts: 11,959
    • View Profile
    • Donate to Member
Re: IDEA: Gracefully close Firefox on PC exit
« Reply #16 on: March 23, 2009, 09:28 AM »
There are always a couple of programs that do not respond well to the OS call to quit when restarting the computer. One that has suddenly started to give me fits is Surfulater 3:

Jim - you could probably get that on 'cured' on the Surfulater forum (if you haven't already!)
Tom

J-Mac

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 2,918
    • View Profile
    • Donate to Member
Re: IDEA: Gracefully close Firefox on PC exit
« Reply #17 on: March 23, 2009, 03:38 PM »
Curt:  I tried it and my machine simply would not reboot at all. Had to force a reboot. I didn't bother trying it again after that.

Tomos: Yep - no reply yet from Neville though. Just posted it a day or so ago.

Thanks!

Jim

J-Mac

  • Supporting Member
  • Joined in 2007
  • **
  • Posts: 2,918
    • View Profile
    • Donate to Member
Re: IDEA: Gracefully close Firefox on PC exit
« Reply #18 on: March 24, 2009, 02:01 AM »
Tom,

Just an update - Neville replied that he has had reports of this same problem and that upcoming changes in how Surfulater's data is stored - specifically to start using an SQL database - will eliminate the problem.

Jim

DyNama

  • Supporting Member
  • Joined in 2010
  • **
  • Posts: 73
  • Are you a good witch or a bad witch?
    • View Profile
    • Donate to Member
Re: IDEA: Gracefully close Firefox on PC exit
« Reply #19 on: December 16, 2010, 09:18 PM »
again restarting an old thread! but i'd like to ask a question: i have up to 8 windows of a picture viewer program open that i forget to close sometimes when i reboot. it remembers what picture it was on and the directory it was in if closed normally. they all have the program name in the window title: VuePrint - JPG File: [<name of file>]. if i just put Close | VuePrint once in Close2Quit, will it close each of them?

Curt

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 7,566
    • View Profile
    • Donate to Member
Re: IDEA: Gracefully close Firefox on PC exit
« Reply #20 on: December 17, 2010, 07:38 AM »
Wellcome at DC, DyNama :-)

I don't think anyone is using Close2Quit, so you will just have to test it, if you dare (I see no reports of success)! Skrommel, the author, is not likely to read this thread. You may want to use apps=VuePrintWindowClass


:) You can use CloseToQuit to close a list of apps, with options to close by using the process name, the class name or a part of a window caption.

To close FireFox just use apps=firefox.exe or apps=MozillaWindowClass.

Skrommel

DyNama

  • Supporting Member
  • Joined in 2010
  • **
  • Posts: 73
  • Are you a good witch or a bad witch?
    • View Profile
    • Donate to Member
Re: IDEA: Gracefully close Firefox on PC exit
« Reply #21 on: December 18, 2010, 03:52 AM »
thanx, Curt! i guess i'll have to try it, because i've always wanted a program that does this. i could have gone ahead and tried it, but 4 reboots ago, my computer shut down and never came back on! it had to be reformatted before the computer booted up again  :( that's why i asked first, these days i keep my reboots to a minimum.

1 other question, a process manager program i use (ykill) says the class is WindowsVuePrintClass. it also says firefox is MozillaUIWindowClass. i know nothing about Classes, so can i use whatever it says as the name of the Class?

Curt

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 7,566
    • View Profile
    • Donate to Member
Re: IDEA: Gracefully close Firefox on PC exit
« Reply #22 on: December 18, 2010, 04:45 AM »
What a terrible experience you have had with your computer.  :(
Personally I reboot several times a day, so I know things are in order.

I know nothing about Classes either...!!, but apps=WindowsVuePrintClass would most likely be the proper term, assuming YKill knows what it is talking about ;-)

So, I guess you are running Windows XP? YKill is very old! You may want to to try a task manager like Process Explorer from Microsoft's Windows Sysinternals: http://technet.micro...6653%28en-us%29.aspx. Many consider it to be The Best freeware task manager.

DyNama

  • Supporting Member
  • Joined in 2010
  • **
  • Posts: 73
  • Are you a good witch or a bad witch?
    • View Profile
    • Donate to Member
Re: IDEA: Gracefully close Firefox on PC exit
« Reply #23 on: December 18, 2010, 11:14 PM »
yes, winXP on a 6-1/2 year old Dell laptop. i only use YKill to identify which of the 8 clones i've made of VuePrint i might have open. all windows taskmanager says is vueprint.exe for each. Registered VuePrint hasn't been updated since 2002, a registered disk catalog i use says "copyright 2004", a registered calendar program i use says "copyright 2003", i even still use a DOS text editor that says "copyright 1987" (it sorts text files by column)! i guess i get used to software and keep using it until i want new features. i'm an unemployed AutoCAD draftsman (20 years!) and i did always use the latest version of that program.

but i'll look at Process Explorer. i love little utilities! while here at DC i downloaded not only Close2Quit, but also windows versions of CAPshift, WasteNot, TenTimer, ListNumberer, CutAway, and Files2Folder.

DyNama

  • Supporting Member
  • Joined in 2010
  • **
  • Posts: 73
  • Are you a good witch or a bad witch?
    • View Profile
    • Donate to Member
Re: IDEA: Gracefully close Firefox on PC exit
« Reply #24 on: December 20, 2010, 12:46 PM »
by jove, Close2Quit worked! i think i just put "VuePrint" as part of the title of the windows in the windows version of C2Q, there were 4 open when i did a restart, and all 4 must have been closed "normally" because the .ini file of each did know where it left off. when i look at the settings of C2Q now, tho, it says "WindowsVuePrintClass".

is there any problem with having multiple copies of AutoHotKey running? i don't run AHK scripts. i put the windows version of C2Q and CAPshift in my startup.