Unc3nZureD Posted December 30, 2013 Posted December 30, 2013 Is there any WM code for getting the following actions?: - GUI Focused - GUI Unfocused I tried to have a look at it in the help file, but I couldn't find for both. Maybe I missed something?
mikell Posted December 30, 2013 Posted December 30, 2013 WM_SETFOCUS & WM_KILLFOCUS But checking WinActive is much easier, can't you use it ?
Solution BrewManNH Posted December 30, 2013 Solution Posted December 30, 2013 $WM_ACTIVATE will fire off when the window gets activated (focused). You'll get $wParam set to 1 or 2 when the window gets activated or clicked on, and 0 when you lose focus on the window. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Unc3nZureD Posted December 30, 2013 Author Posted December 30, 2013 Thanks I will try, anyways it's easier (and probably some more resource-friendlier) to set up a GUIRegisterMsg then looping a WinActive all the time
BrewManNH Posted December 30, 2013 Posted December 30, 2013 This is a piece of code that will show you it in action, it's a stripped down version of the GUIRegisterMsg demo linked in my signature. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $msg GUIRegisterMsg($WM_ACTIVATE, "WM_ACTIVATE") $GUI = GUICreate("Test GUI", 200, 200, -1, -1, BitOR($WS_THICKFRAME, $gui_ss_default_gui, $WS_MAXIMIZEBOX)) $Button = GUICtrlCreateButton("Test", 20, 20) $Button2 = GUICtrlCreateButton(" Another Test ", 20, 100) $Slider = GUICtrlCreateSlider(20, 60, 150) $hSlider = GUICtrlGetHandle($Slider) $hCheck = GUICtrlCreateCheckbox("test", 20, 150) $Edit = GUICtrlCreateEdit("", 20, 170, 180) $hEdit = GUICtrlGetHandle($Edit) ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hEdit = ' & $hEdit & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console GUISetState() While 1 $msg = GUIGetMsg() Switch $msg Case $Button MsgBox(0, "", "You pressed the button marked TEST") Case $Button2 MsgBox(0, "", "You pressed the button marked 'Another Test'") Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func WM_ACTIVATE($hWnd, $iMsg, $wParam, $lParam) Local $nNotifyCode = BitShift($wParam, 16) Local $nID = BitAND($wParam, 0x0000FFFF) Local $hCtrl = $lParam #forceref $hWnd, $iMsg, $wParam, $lParam Switch $iMsg Case $WM_ACTIVATE Switch $wParam Case 1, 2 ConsoleWrite("!Window Activated" & @CRLF) Case 0 ConsoleWrite("!Window Deactivated" & @CRLF) Case Else MsgBox(0, "WM_ACTIVATE ", "GUIHWnd" & @TAB & ":" & $hWnd & @LF & _ "MsgID" & @TAB & ":" & $msg & @LF & _ "wParam" & @TAB & ":" & $wParam & @LF & _ "lParam" & @TAB & ":" & $lParam & @LF & @LF & _ "MY_WM_SYSCOMMAND - Infos:" & @LF & _ "-----------------------------" & @LF & _ "Code" & @TAB & ":" & $nNotifyCode & @LF & _ "CtrlID" & @TAB & ":" & $nID & @LF & _ "CtrlHWnd" & @TAB & ":" & $hCtrl) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_ACTIVATE If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Unc3nZureD Posted December 30, 2013 Author Posted December 30, 2013 Is there any documentation which describes all theese WM codes including their "return values"
BrewManNH Posted December 31, 2013 Posted December 31, 2013 (edited) MSDN Search for the windows message on Google to find the relevant information. The MSDN site is nearly always the first one listed. Edited December 31, 2013 by BrewManNH If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Unc3nZureD Posted December 31, 2013 Author Posted December 31, 2013 (edited) It always show how to use it, not a list what it returns. Probably I'm stupid, but can't find a good one Found it, however it's much different than I expected Just if anyone needs it later here's the current link: http://msdn.microsoft.com/en-us/library/windows/desktop/ms644927%28v=vs.85%29.aspx#windows_messages Edited December 31, 2013 by Unc3nZureD
BrewManNH Posted December 31, 2013 Posted December 31, 2013 It always show how to use it, not a list what it returns. Really? Because when I searched for WM_ACTIVATE I found this link on MSDN which says exactly what the wParam values will be, which is what I used in the demo above. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
Unc3nZureD Posted December 31, 2013 Author Posted December 31, 2013 Oh, I mean a complete list what all the WM messages give generally.
BrewManNH Posted December 31, 2013 Posted December 31, 2013 I'm sure there's such a list out there, I just haven't run across one yet. I agree, it would be nice to know which one to use, rather than having to make a generic search for what you're hoping to find. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator
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