gsb Posted March 1, 2007 Share Posted March 1, 2007 I am still to new to know all that's in the help files. And my search failed to get me going. The question is for the control to "know" when it is given system focus. An example would be when top most window is deleted and the control underneath now gains focus. Is there an event I could capture and use at this time? Thanks. All here are a great help in my learning how to use AutoIt. gsb "Did you ever stop to think? ...and forget to restart!" Link to comment Share on other sites More sharing options...
_Kurt Posted March 2, 2007 Share Posted March 2, 2007 Not exactly what you mean, but you can use $GUI_FOCUS. Example: #include <GUIConstants.au3> GUICtrlSetState($control, $GUI_FOCUS) ;Will give focus to a control Kurt Awaiting Diablo III.. Link to comment Share on other sites More sharing options...
xcal Posted March 2, 2007 Share Posted March 2, 2007 Check out GUIGetCursorInfo in the help file and look at the 4th element the array returns. You could stick that in a loop and watch that. How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 2, 2007 Moderators Share Posted March 2, 2007 Check out GUIGetCursorInfo in the help file and look at the 4th element the array returns. You could stick that in a loop and watch that.That or use GUIRegisterMsg() with it. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
gsb Posted March 2, 2007 Author Share Posted March 2, 2007 (edited) Thanks both of you but... I think they are not quite it. I do not need to give it focus but rather find out when the system gives focus to the window. Like in a "tag, your it!" kind of way. Any more ideas? ...thanks. ***EDIT: Sorry SmOke_N. I over posted... slow at typing here. But looks like that may be it with WM_ACTIVATE perhaps. I will try when I get home... Work calls just now. gsb Edited March 2, 2007 by gsb "Did you ever stop to think? ...and forget to restart!" Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 2, 2007 Moderators Share Posted March 2, 2007 Thanks both of you but... I think they are not quite it.I do not need to give it focus but rather find out when the system gives focus to the window.Like in a "tag, your it!" kind of way.Any more ideas? ...thanks.gsbIf it's a window and not a control... If WinActive() Then...Tag... you're it. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
gsb Posted March 2, 2007 Author Share Posted March 2, 2007 So here is what I ended up with and it works just fine, TYVM: $myWinTitle = "gsb Test GUI" $Main = GUICreate( $myWinTitle, 200, 100) GUISetState() $lastWinActive = 1 While 1 Switch GUIGetMsg() Case -3 Exit EndSwitch $currentWinActive = WinActive( $myWinTitle ) If ($currentWinActive == 1) AND ($lastWinActive == 0) Then MsgBox(64,"Win Active", $myWinTitle & " went active. ", 3) EndIf $lastWinActive = $currentWinActive WEnd Any improvements are welcomed. Again, thanks all. gsb "Did you ever stop to think? ...and forget to restart!" Link to comment Share on other sites More sharing options...
MrCreatoR Posted March 2, 2007 Share Posted March 2, 2007 (edited) gsb Any improvements are welcomed.Just litle shorter : $myWinTitle = "gsb Test GUI" $Main = GUICreate( $myWinTitle, 200, 100) GUISetState() While GUIGetMsg() <> -3 If WinActive($myWinTitle) Then MsgBox(64,"Win Active", $myWinTitle & " went active. ", 3) Sleep(10) WEnd Edited March 2, 2007 by MsCreatoR Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
MrCreatoR Posted March 2, 2007 Share Posted March 2, 2007 Or if i understand right, this will be more correct for you mission $myWinTitle = "gsb Test GUI" $Main = GUICreate( $myWinTitle, 200, 100) GUISetState() $lastWinActive = 1 While GUIGetMsg() <> -3 $currentWinActive = WinActive( $myWinTitle ) If $currentWinActive AND Not $lastWinActive Then MsgBox(64,"Win Active", $myWinTitle & " went active. ", 3) $lastWinActive = $currentWinActive WEnd Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team Link to comment Share on other sites More sharing options...
gsb Posted March 2, 2007 Author Share Posted March 2, 2007 Thanks MsCreatoR, Your second example is more what I am doing. But I do need the switch for in the application I have many other events to respond to. I stripped it here for the essentials. The shorthand code for the if I will use, Thank you. gsb "Did you ever stop to think? ...and forget to restart!" 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