Archive: Can't make windows go away


Can't make windows go away
I'm using kichik's WinList program to obtain window classes and window names for all the windows in my app, so I can provide a shortcut to stop execution of the app. When I launch the executable that does this, the app GUI and tray icon go away, but most of the windows that I tried to close are still shown to be alive in WinList, and the corresponding Windows process is therefore still running.

I've tried WM_CLOSE, WM_QUIT, and WM_DESTROY, but most of he windows remain. My script is below, and I've attached before and after screen captures (to this post and the next one), to show you what I see in WinList before and after executing the script.

Does anyone have any idea how I can make these windows go away?

; Stop RCB Client
;--------------

Name "StopRCB"
Caption "Stop RCB Client"
OutFile "stopRCBClient.exe"

SilentInstall silent
AutoCloseWindow true
ShowInstDetails neverShow

!include WinMessages.nsh
#Module | Window Class from WinList
#tray.dll | JDIC Tray
!define TRAY_WNDCLASS "JDIC_Tray"
!define TRAY_WNDTITLE "Tray Window"
#awt.dll | SunAwtDialog
!define ICON_WNDCLASS "SunAwtDialog"
!define ICON_WNDTITLE "JDIC Tray Icon"
#awt.dll | SunAwtToolkit
!define TK_WNDCLASS "SunAwtToolkit"
!define TK_WNDTITLE "theAwtToolkitWindow"
#awt.dll | IME
!define IME_WNDCLASS "IME"
!define IME_WNDTITLE "Default IME"
#msctfime.ime | MSCTFIME UI
!define MSCT_WNDCLASS "MSCTFIME UI"
!define MSCT_WNDTITLE "M"
#awt.dll SunAwtFRame
!define GUI_WNDCLASS "SunAwtFrame"
!define GUI_WNDTITLE "RCB Control Panel"

Section ""
Call stopClient
SectionEnd

Function stopClient
Var /GLOBAL window_found
strCpy $window_found "false"
checkTrayWindow:
FindWindow $0 "${TRAY_WNDCLASS}" "${TRAY_WNDTITLE}"
StrCmp $0 0 checkIconWindow
DetailPrint "Closing tray window"
SendMessage $0 ${WM_CLOSE} 0 0
SendMessage $0 ${WM_QUIT} 0 0
SendMessage $0 ${WM_DESTROY} 0 0
strCpy $window_found "true"
checkIconWindow:
FindWindow $0 "${ICON_WNDCLASS}" "${ICON_WNDTITLE}"
StrCmp $0 0 checkTKWindow
DetailPrint "Closing icon window"
SendMessage $0 ${WM_CLOSE} 0 0
SendMessage $0 ${WM_QUIT} 0 0
SendMessage $0 ${WM_DESTROY} 0 0
strCpy $window_found "true"
checkTKWindow:
FindWindow $0 "${TK_WNDCLASS}" "${TK_WNDTITLE}"
StrCmp $0 0 checkIMEWindow
DetailPrint "Closing toolkit window"
SendMessage $0 ${WM_CLOSE} 0 0
SendMessage $0 ${WM_QUIT} 0 0
SendMessage $0 ${WM_DESTROY} 0 0
strCpy $window_found "true"
checkIMEWindow:
FindWindow $0 "${IME_WNDCLASS}" "${IME_WNDTITLE}"
StrCmp $0 0 checkMSCTWindow
DetailPrint "Closing IME window"
SendMessage $0 ${WM_CLOSE} 0 0
SendMessage $0 ${WM_QUIT} 0 0
SendMessage $0 ${WM_DESTROY} 0 0
strCpy $window_found "true"
checkMSCTWindow:
FindWindow $0 "${MSCT_WNDCLASS}" "${MSCT_WNDTITLE}"
StrCmp $0 0 checkGUI
DetailPrint "Closing MSCT window"
SendMessage $0 ${WM_CLOSE} 0 0
SendMessage $0 ${WM_QUIT} 0 0
SendMessage $0 ${WM_DESTROY} 0 0
strCpy $window_found "true"
checkGUI:
FindWindow $0 "${GUI_WNDCLASS}" "${GUI_WNDTITLE}"
StrCmp $0 0 checkGUI2
DetailPrint "closing GUI window"
SendMessage $0 ${WM_CLOSE} 0 0
SendMessage $0 ${WM_QUIT} 0 0
SendMessage $0 ${WM_DESTROY} 0 0
strCpy $window_found "true"
checkGUI2:
FindWindow $0 "${GUI_WNDCLASS}" ""
StrCmp $0 0 done
DetailPrint "closing GUI2 window"
SendMessage $0 ${WM_CLOSE} 0 0
SendMessage $0 ${WM_QUIT} 0 0
SendMessage $0 ${WM_DESTROY} 0 0
strCpy $window_found "true"
done:
strCmp $window_found "false" 0 exit
MessageBox MB_OK|MB_TOPMOST "The RCB Client window could not be found. If you think$\r\
this is an error, look for a process named javaw and stop$\r\
it. But be aware that other Java processes may also be$\r\
named javaw."
exit:
return
FunctionEnd

Here's the "after" screen capture


Try one of the available plugins, FCT for instance,

http://nsis.sourceforge.net/FCT_plug-in


I released WinList? Where?


Maybe there's another kichik...


Originally posted by kichik
I released WinList? Where?
I got it from this thread. Isn't that you?

http://forums.winamp.com/showthread....running+kichik

That is me. I was just under the impression I wrote it for my own use and never released it. I was a bit shocked to see that screenshot which looked exactly like winlist. Nice to see it's useful for something :)


Yes, kichik, it came in quite handy for me, since I'm trying to kill a Java app, and I didn't know what the window class and title would be as assigned by the JVM. So thanks for sharing it.

And Red Wine, thanks for the tip on FCT. It works perfectly. And I only had to check for one of the windows out of the whole lot, and it killed the process as desired.


Obviously there's only one kichik! That's cool ;)