JerryD Posted March 12, 2006 Posted March 12, 2006 How about... Global Const $WinExists = 1; Window exists Global Const $WinIsVisible = 2; Window is visible Global Const $WinIsEnabled = 4; Windows is enabled Global Const $WinIsActive = 8; Window is active Global Const $WinIsMinimized = 16; Window is minimized Global Const $WinIsMaximized = 32; Windows is maximized Global Const $WinActiveNormal = $WinExists + $WinIsVisible + $WinIsEnabled + $WinIsActive Global Const $WinActiveMaximized = $WinExists + $WinIsVisible + $WinIsEnabled + $WinIsActive + $WinIsMaximized HotKeySet ( '{F9}', 'MyExit' ) HotKeySet ( '{f11}', 'CloseWindow' ) While 1 Sleep ( 100 ) WEnd Func CloseWindow() Local $i, $iWinState, $aWinList $aWinList = WinList() For $i = 1 to $aWinList[0][0] $iWinState = WinGetState ( $aWinList[$i][0] ) If ( $iWinState = $WinActiveNormal OR $iWinState = $WinActiveMaximized ) AND $aWinList[$i][0] <> '' Then ; MsgBox ( 0, 'Close this window?', $aWinList[$i][0] ) ; WinKill ( $aWinList[$i][0] WinClose ( $aWinList[$i][0] ) EndIf Next EndFunc Func MyExit() Exit EndFunc I had to use {F11} because for some reason F12 isn't working on my system! I left the debugging line and WinKill in but commented out. From the documentation and comments here, WinClose sounds like the way to go though.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now