Here is what I did to close firefox,
FindWindow $0 'MozillaWindowClass' ''
${If} $0 <> 0
SendMessage $0 ${WM_CLOSE} 0 0
${EndIf}
But it doesn't work. How can I achieve that? Thanks.
How to close firefox in nsis?
21 posts
!include LogicLib.nsh
loop:
FindWindow $0 "MozillaUIWindowClass"
${If} $0 <> 0
SendMessage $0 0x0112 0xF060 0
Sleep 250
goto loop
${EndIf} If firefox has "confirm close with multiple tabs open", who knows what will happen, you might want to limit the loop to 50 retries or so...Thanks for your reply. It doesn't work. FindWindow $0 "MozillaUIWindowClass" always set $0 to zero. Any further ideas? Thank you very much!Originally Posted by Anders View PostIf firefox has "confirm close with multiple tabs open", who knows what will happen, you might want to limit the loop to 50 retries or so...!include LogicLib.nsh loop: FindWindow $0 "MozillaUIWindowClass" ${If} $0 <> 0 SendMessage $0 0x0112 0xF060 0 Sleep 250 goto loop ${EndIf}
It worked when I tested it (Firefox 3.6) The class name is a internal thing and could change between releases. Use http://catch22.net/software/winspy to find the class name
Firefox 4 is just called MozillaWindowClass.
Stu
Stu
It works in firefox 3.6 but it doesn't work in firefox 4 even though I use class name "MozillaWindowClas" for firefox 4(I find out this name by using Spy++). Any idea why it doesn't work in firefox 4?Originally Posted by Anders View PostIt worked when I tested it (Firefox 3.6) The class name is a internal thing and could change between releases. Use http://catch22.net/software/winspy to find the class name
Yes, you are right.Originally Posted by Afrow UK View PostFirefox 4 is just called MozillaWindowClass.
Stu
well, the message is WM_SYSCOMMAND + SC_CLOSE so it should work, but you could try WM_CLOSE as well, and if both fail, bring out the big hammer and call DestroyWindow with the system plugin...
(But why not just ask the user to close firefox? They might want to save bookmarks etc)
(But why not just ask the user to close firefox? They might want to save bookmarks etc)
I tried both WM_SYSCOMMAND + SC_CLOSE and WM_CLOSE in Firefox 4. They don't work. If you like, you can try them in Firefox 4 too. It won't take much time if you already tried it in Firefox 3.6. They just simply don't work.Originally Posted by Anders View Postwell, the message is WM_SYSCOMMAND + SC_CLOSE so it should work, but you could try WM_CLOSE as well, and if both fail, bring out the big hammer and call DestroyWindow with the system plugin...
(But why not just ask the user to close firefox? They might want to save bookmarks etc)
Could you give me an example how to use DestroyWindow with the system plugin? Thanks a lot.
!include LogicLib.nsh
StrCpy $1 0
loop:
FindWindow $0 "MozillaUIWindowClass"
${IfThen} $0 = 0 ${|} FindWindow $0 "MozillaWindowClass" ${|}
${If} $0 <> 0
SendMessage $0 0x0112 0xF060 0
Sleep 500
IntOp $1 $1 + 1
IntCmp $1 25 "" loop
${EndIf} This works in both 3.6 and 4 on XP (In my non standard FF configuration), but like I said, you should ask the user, not close the windows on your own.I know there is "confirm close" dialog in firefox when the user closes firefox. Right now, I just could not trigger this dialog no matter what I do. Do you have any idea how to achieve that? Thanks a lot.Originally Posted by Anders View PostThis works in both 3.6 and 4 on XP (In my non standard FF configuration), but like I said, you should ask the user, not close the windows on your own.!include LogicLib.nsh StrCpy $1 0 loop: FindWindow $0 "MozillaUIWindowClass" ${IfThen} $0 = 0 ${|} FindWindow $0 "MozillaWindowClass" ${|} ${If} $0 <> 0 SendMessage $0 0x0112 0xF060 0 Sleep 500 IntOp $1 $1 + 1 IntCmp $1 25 "" loop ${EndIf}
I think you should change your strategy. Ask the user to close Firefox themselves. You can either do this with your own code (similar to what we use in this topic) or use a plug-in such as LockedList.
Stu
Stu
So should I just call MessageBox MB_OK "Please Close Firefox" in the script? Thanks.Originally Posted by Afrow UK View PostI think you should change your strategy. Ask the user to close Firefox themselves. You can either do this with your own code (similar to what we use in this topic) or use a plug-in such as LockedList.
Stu
i think yes!
i would never install a program that will automatically taskkill my firefox.exe!
Take a look at that LockedList plugin as Afrow UK suggested.
What you have to use depends on your purpose/program. but never kill a task on the user system unasked !!!
bye
i would never install a program that will automatically taskkill my firefox.exe!
Take a look at that LockedList plugin as Afrow UK suggested.
What you have to use depends on your purpose/program. but never kill a task on the user system unasked !!!
bye
You don't just have to have a message box. Using FindWindow you can detect whether Firefox has been closed or not and keep asking them to close Firefox until FindWindow returns 0. Using LockedList has more features of course.
Stu
Stu
I don't quite get what you meant. Without using message box, how can I "keep asking them to close Firefox"? I should have some way to inform the users of closing the firefox, right? Thanks.Originally Posted by Afrow UK View PostYou don't just have to have a message box. Using FindWindow you can detect whether Firefox has been closed or not and keep asking them to close Firefox until FindWindow returns 0. Using LockedList has more features of course.
Stu
...
He means that you have not to show this messegebox always. You can use the "find firefox window" checkup to show the messagebox only if firefox is open.
He means that you have not to show this messegebox always. You can use the "find firefox window" checkup to show the messagebox only if firefox is open.
!include LogicLib.nsh
StrCpy $1 0
loop:
FindWindow $0 "MozillaUIWindowClass"
${IfThen} $0 = 0 ${|} FindWindow $0 "MozillaWindowClass" ${|}
${If} $0 <> 0
MessageBox MB_OK|MB_ICONSTOP|MB_TOPMOST|MB_SETFOREGROUND "Close Firefox now and press ok to continue."
goto loop
${EndIf} cheersYou should create a new profile: firefox.exe -POriginally Posted by JohnChen View PostI know there is "confirm close" dialog in firefox when the user closes firefox. Right now, I just could not trigger this dialog no matter what I do. Do you have any idea how to achieve that? Thanks a lot.
and create a new profile for testing.
Would it not achieve the same affect to do the following...
Squirre1
!insertmacro logme ${INSTLOG} "Locating and terminating running firefox.exe processes" b
${nsProcess::FindProcess} "firefox.exe" $0
${If} $0 == '0'
!insertmacro logme ${INSTLOG} "- Running Process Found: firefox.exe" l
!insertmacro logme ${INSTLOG} "- Terminating Process: firefox.exe" l
${nsProcess::KillProcess} "firefox.exe" $0
!insertmacro logme ${INSTLOG} "- Terminate Process Returned Code: $0" l
${Else}
!insertmacro logme ${INSTLOG} "- Running Process Not Found: firefox.exe" l
${EndIf} Disregard the logme macros, that is a making of my own... Depends on what you are trying to accomplish though, but this is what I use.Squirre1
That will not work if and when they make an official 64-bit build of Firefox. FindWindow is safer (when you have a class name).
Stu
Stu