Achilles Posted July 30, 2008 Share Posted July 30, 2008 (edited) For a small script I'm writing I want my window do be hidden if it looses focus. I don't want to have my computer checking every 20ms with If WinActive()... I know there is an easier way but I'm not sure what it is. Any ideas? I was thinking using a GUIRegisterMsg() of some sort but I'm not sure what the parameters would be. Edit: Found out that using WM_COMMAND it calls the function whenever the window is loose or gains focus, anybody know what the handle of the item that is triggering this? I thought it might be the GUI but it isn't. I'll post an example in a second... Edited July 30, 2008 by Achilles My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
BrettF Posted July 30, 2008 Share Posted July 30, 2008 I was thinking something like: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $hGUI = GUICreate("My Ownerdrawn Created Button", 300, 200) ;GUICtrlCreateInput ("", 10, 10) ;GUICtrlCreateInput ("", 10, 30) GUIRegisterMsg($WM_KILLFOCUS, "KILL_FOCUS") GUISetState() While 1 $GUIMsg = GUIGetMsg() Switch $GUIMsg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Func KILL_FOCUS($hWnd, $Msg, $wParam, $lParam) MsgBox (0, $hGUI, $hWnd & @CRLF & $Msg & @CRLF & $wParam & @CRLF & $lParam) EndFunc But as soon I added the input boxes, it stopped working... But its closer Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version! Link to comment Share on other sites More sharing options...
rasim Posted July 30, 2008 Share Posted July 30, 2008 (edited) AchillesHi, try this:#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> Global $Active = False $hGUI = GUICreate("Test", 300, 200) GUIRegisterMsg($WM_ACTIVATE, "WM_ACTIVATE") GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func WM_ACTIVATE($hWnd, $Msg, $wParam, $lParam) $Active = Not $Active If $Active Then ConsoleWrite("-> Focused" & @LF) Else ConsoleWrite("-> Focus loosed" & @LF) EndIf Return $GUI_RUNDEFMSG EndFunc Edited July 30, 2008 by rasim Link to comment Share on other sites More sharing options...
Achilles Posted July 30, 2008 Author Share Posted July 30, 2008 @Bert, wait... BrettF: I just tried KILL_FOCUS @rasim: I think that works... I'm getting too sleepy to test it much more but I'll look into it more tomorrow (or later today actually). My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] 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