zfisherdrums Posted July 20, 2008 Share Posted July 20, 2008 (edited) TASK: Attempting to retrieve control position. ID 1017 is consistent between app sessions and other automation concerns require the use of this ID, e.g. cannot use ClassNameNN.PROBLEM: When using passing in the ID, I receive a different handle than if I had used ClassnameNN, etc. I saw nothing on the forums previously and am in hopes someone can explain this behavior and knows of a consistent workaround.EDIT: Figured it out. The app has another control with the same ID that appears in another #32770 window. I believe that because it is higher in the tree, it takes precedence. Using ID and INSTANCE returns the wrong handle. Any workarounds would be welcome, but I'm not sure if its possible on this side of the app. Window Info:>>>> Window <<<< Title: Connections - Client Input Class: demo60.exeWindowClass Position: -4, -4 Size: 1160, 844 Style: 0x15CFC000 ExStyle: 0x00000100 Handle: 0x00080590 >>>> Control <<<< Class: ComboBox Instance: 4 ClassnameNN: ComboBox4 Advanced (Class): [CLASS:ComboBox; INSTANCE:4] ID: 1017 Text: Position: 292, 226 Size: 165, 21 ControlClick Coords: 61, 9 Style: 0x50010203 ExStyle: 0x00000004 Handle: 0x001A07EETest:ConsoleWrite("Using Class+Instance..." & @CRLF) $handle = ControlGetHandle("Connections - Client", "", "[CLASS:ComboBox; INSTANCE:4]" ) ConsoleWrite("HWND: " & $handle & @CRLF) $res = ControlGetPos("Connections - Client", "", "[CLASS:ComboBox; INSTANCE:4]" ) ConsoleWrite( "Position: " & $res[0] & ", " & $res[1] & @CRLF) ConsoleWrite( @CRLF) ConsoleWrite("Using ID..." & @CRLF) $handle = ControlGetHandle("Connections - Client", "", "[ID:1017]" ) ConsoleWrite("HWND: " & $handle & @CRLF) $res = ControlGetPos("Connections - Client", "", "[ID:1017]" ) ConsoleWrite( "Position: " & $res[0] & ", " & $res[1] & @CRLF) ConsoleWrite( @CRLF) ConsoleWrite("Using ClassnameNN..." & @CRLF) $handle = ControlGetHandle("Connections - Client", "", "ComboBox4" ) ConsoleWrite("HWND: " & $handle & @CRLF) $res = ControlGetPos("Connections - Client", "", "ComboBox4" ) ConsoleWrite( "Position: " & $res[0] & ", " & $res[1] & @CRLF)Output:Using Class+Instance... HWND: 0x001A07EE Position: 292, 226 Using ID... HWND: 0x000805CE Position: 977, 378 Using ClassnameNN... HWND: 0x001A07EE Position: 292, 226 Edited July 20, 2008 by zfisherdrums Identify .NET controls by their design time namesLazyReader© could have read all this for you. Unit Testing for AutoItFolder WatcherWord Doc ComparisonThis here blog... Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 21, 2008 Share Posted July 21, 2008 If there are multiple windows with the same title, start using WinTitleMatchMode = 4 and "[CLASS:demo60.exeWindowClass; TITLE:Connections - Client Input]" or "[CLASS:#32770; TITLE:Connections - Client Input]" choose which window you want. muttley 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...
zfisherdrums Posted July 22, 2008 Author Share Posted July 22, 2008 PsaltyDS, Man, thank you so much for the advice. I tried it but to no avail. I believe the problem here is that the #32770 windows are part of an MDI belonging to the "Connections" application. I wish there was a way to natively specify an instance of an internal control ID, or even specify AutoIt to only traverse all child controls of a specific control, instead of an application window. Perhaps this would be a bit like asking the sun not to shine so bright in my window each morning; this "problem" is mine alone. Zach... Identify .NET controls by their design time namesLazyReader© could have read all this for you. Unit Testing for AutoItFolder WatcherWord Doc ComparisonThis here blog... 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