BamBam0099 Posted June 11, 2008 Share Posted June 11, 2008 I'm a newbie with AutoIT and was looking at it's capabilites for a situation I have. Here is the scenario. I need an app that will run all the time, waiting for new 'InFocus' events and then be able to determine what object got focus and the parent app. Take for instance a custom VB app named 'AddressBook.exe' that has many text box entries with one named _classFirstName. I need an autoit app that triggers on onfocus events that can be tested so when the _classFirstName text field of the AddressBook.exe application gets focus, I can perform some type of operation. Is this a difficult task and is there existing source anywhere that I could look at for an example? Thanks in advance to all who respond...appreciate it Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 11, 2008 Share Posted June 11, 2008 I'm a newbie with AutoIT and was looking at it's capabilites for a situation I have.Here is the scenario. I need an app that will run all the time, waiting for new 'InFocus' events and then be able to determine what object got focus and the parent app.Take for instance a custom VB app named 'AddressBook.exe' that has many text box entries with one named _classFirstName. I need an autoit app that triggers on onfocus events that can be tested so when the _classFirstName text field of the AddressBook.exe application gets focus, I can perform some type of operation.Is this a difficult task and is there existing source anywhere that I could look at for an example?Thanks in advance to all who respond...appreciate it$hWinFocus = WinGetHandle("") ; Get handle of current active window$ctrlFocus = ControlGetFocus($hWinFocus) ; Get ClassNameNN of control with focus in window$hCtrlFocus = ControlGetHandle($hWinFocus, "", $ctrlFocus) ; Get handle of control with focus Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
BamBam0099 Posted June 11, 2008 Author Share Posted June 11, 2008 $hWinFocus = WinGetHandle("") ; Get handle of current active window$ctrlFocus = ControlGetFocus($hWinFocus) ; Get ClassNameNN of control with focus in window$hCtrlFocus = ControlGetHandle($hWinFocus, "", $ctrlFocus) ; Get handle of control with focus Thanks for the reply. I saw those function calls in the help file but what I was looking for specifically is a trigger (eg like a database trigger on add or update) that would fire on onfocus events. I am looking for this type of approach vs. polling in an endless loop. Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 12, 2008 Share Posted June 12, 2008 Thanks for the reply. I saw those function calls in the help file but what I was looking for specifically is a trigger (eg like a database trigger on add or update) that would fire on onfocus events. I am looking for this type of approach vs. polling in an endless loop.I thought there would be a $WM_onfocus or some similar message you could register with GuiRegisterMsg(), but I couldn't find it outside of HTML/Java Script contexts. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 12, 2008 Share Posted June 12, 2008 I thought there would be a $WM_onfocus or some similar message you could register with GuiRegisterMsg(), but I couldn't find it outside of HTML/Java Script contexts. Found another answer in another topic: #include <GUIConstants.au3> #include <EditConstants.au3> #include <WindowsConstants.au3> Global $hGUI = GUICreate("Test GUI", 300, 200) $IdEdit1 = GUICtrlCreateEdit("Edit1", 10, 10, 280, 85) ConsoleWrite("Debug: $IdEdit1 = " & $IdEdit1 & @LF) $IdEdit2 = GUICtrlCreateEdit("Edit2", 10, 105, 280, 85) ConsoleWrite("Debug: $IdEdit2 = " & $IdEdit2 & @LF) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUISetState(@SW_SHOW) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam) ConsoleWrite("Debug: $wParam = " & $wParam & @LF) Local $wParamLow = BitAND($wParam, 0xFFFF) ConsoleWrite("Debug: $wParamLow = " & $wParamLow & @LF) Local $wParamHigh = BitShift($wParam, 16) ConsoleWrite("Debug: $wParamHigh = " & $wParamHigh & @LF) Switch $wParamLow Case $IdEdit1 Switch $wParamHigh Case $EN_SETFOCUS ConsoleWrite("Debug: Edit1 received focus!" & @LF) EndSwitch EndSwitch EndFunc Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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