VAN0 Posted May 25, 2014 Share Posted May 25, 2014 Hello.Normally there are 3 ways to close a window:1. click on X button2. click on window icon and select close3. alt+f4Is there a way detect each of these methods separately?Thank you. Link to comment Share on other sites More sharing options...
jguinch Posted May 25, 2014 Share Posted May 25, 2014 (edited) Is it for a AutoIt GUI or an external window ? For a GUI made with AutoIt, you can try something like this : #include <WindowsConstants.au3> #include <Misc.au3> Global Const $SC_CLOSE = 0xF060 GUIRegisterMsg($WM_SYSCOMMAND, "WM_SYSCOMMAND") GUICreate("gui") Local $msg Local $exit = GUICtrlCreateButton("Exit", 10, 10, 200, 25) GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $exit ConsoleWrite("Closed with Exit button" & @CRLF) Exit EndSwitch WEnd Func WM_SYSCOMMAND($hWndGUI, $MsgID, $WParam, $LParam) If $WParam = $SC_CLOSE Then If _IsPressed("12") And _IsPressed("73") Then ConsoleWrite("Closed with ALT + F4" & @CRLF) ElseIf _IsPressed("1B") Then ConsoleWrite("Closed with ESC" & @CRLF) Else ConsoleWrite("Closed with X " & @CRLF) EndIf Exit EndIf EndFunc Edited May 25, 2014 by jguinch VAN0 1 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
VAN0 Posted May 29, 2014 Author Share Posted May 29, 2014 Very good. Thank you.Any way capture if it was closed via window icon menu? In your example it shows as "Close with X"Thanks. Link to comment Share on other sites More sharing options...
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