How to close firefox in nsis?
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.
Archive: How to close firefox in nsis?
How to close firefox in nsis?
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.
!include LogicLib.nshIf 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...
loop:
>FindWindow $0 "MozillaUIWindowClass"
>${If} $0 <> 0
SendMessage$0 0x0112 0xF060 0
Sleep 250
goto loop
>${EndIf}
Originally posted by AndersThanks for your reply. It doesn't work. FindWindow $0 "MozillaUIWindowClass" always set $0 to zero. Any further ideas? Thank you very much!
!include LogicLib.nshIf 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...
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
Originally posted by AndersIt 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?
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
Originally posted by Afrow UKYes, you are right.
Firefox 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)
Originally posted by AndersI 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.
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)
!include LogicLib.nshThis 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.
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}
Originally posted by AndersI 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.
!include LogicLib.nshThis 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.
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
Originally posted by Afrow UKSo should I just call MessageBox MB_OK "Please Close Firefox" in the script? Thanks.
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
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
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
Originally posted by Afrow UKI 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.
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
...
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.nshcheers
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}
Originally posted by JohnChenYou should create a new profile: firefox.exe -P
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.
Would it not achieve the same affect to do the following...
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.!insertmacro logme ${INSTLOG} "Locating and terminating running firefox.exe processes" b
insertmacro logme ${INSTLOG} "- Running Process Not Found: firefox.exe" l
${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}
!
${EndIf}
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
Firefox 4 is just called MozillaWindowClass.
_________________
noi that fami,noi that 190|