DakotaSmyth Posted March 23, 2007 Share Posted March 23, 2007 Hello, I am new to AutoIT (just got it yesterday) and I am already loving it, but I am having a little trouble. I am trying to automate my way through a program, but I do not wish to use the MouseClick command. I am trying to use the ControlClick command, however, the ControlID on the object I need to click on is dynamic and it changes everytime the program runs. I am wondering if there is a script that can be written to get the ControlID of an object and return it in a variable that I can place in the ControlClick command... for example: Dim $CtrlID *YayGetTheControlIDScript* ControlClick("Management Form", "", "$CtrlID") can this be done? Any help would be greatly appreciated. Link to comment Share on other sites More sharing options...
quaizywabbit Posted March 24, 2007 Share Posted March 24, 2007 have a look at ANYGUI in my signature... _GuiTarget( ) will accept x and y coordinates of a point that falls within a particular control(in CLIENT coords) and get the hwnd to it. Those .Net apps are such a pain..... [u]Do more with pre-existing apps![/u]ANYGUIv2.8 Link to comment Share on other sites More sharing options...
jvanegmond Posted March 24, 2007 Share Posted March 24, 2007 Yeah... or use the CLASSNAME OF THE CONTROL. github.com/jvanegmond Link to comment Share on other sites More sharing options...
DakotaSmyth Posted March 26, 2007 Author Share Posted March 26, 2007 (edited) Both good suggestions, however, the coordinates of the window change every time it is initialized, and the ClassName changes as well as the ControlID... what's a guy to do? Is there a way to tell the control a proposed coordinate from say, the top left corner of the window? so instead of it being a coordinate from the entire screen, it measures the x and y values from the corner of the currently active window? (if this isn't possible now, I think this should definitely be implemented somewhere in a future version) Edited March 26, 2007 by DakotaSmyth Link to comment Share on other sites More sharing options...
DakotaSmyth Posted March 26, 2007 Author Share Posted March 26, 2007 (edited) I really just need a way to find the ControlID of an object (such as a textbox) so i can read what's typed into the object, compare what was read to text I have in another file, and then create a logfile of whether they matched or didn't. Edited March 26, 2007 by DakotaSmyth Link to comment Share on other sites More sharing options...
DakotaSmyth Posted March 26, 2007 Author Share Posted March 26, 2007 Your ANYGUI signature got me to understand the concept (very well put together, btw ), but what I am trying to do is get the ControlID for an object that I didn't create and that is automatically made when the program starts what I'm trying to do is all user-based. I'm not trying to create my own GUI, I'm trying to read others. Link to comment Share on other sites More sharing options...
quaizywabbit Posted March 26, 2007 Share Posted March 26, 2007 (edited) use Client coords with _GuiTarget() [its an option in Au3Info tool]doesn't have to add anything, but it will get the hwnd to the control.....if you study the function there's a snippet in ther to get the ControlId (though most Autoit func's will accept hwnd in place of controlid.) Edited March 26, 2007 by quaizywabbit [u]Do more with pre-existing apps![/u]ANYGUIv2.8 Link to comment Share on other sites More sharing options...
eltorro Posted April 11, 2007 Share Posted April 11, 2007 If you have hwnd then you can use this code: ;=============================================================================== ; Function Name: GetDlgCtrlID ; Description: Get CtrlId from Handle ; Parameter(s): $hwnd Handle of control ; Requirement(s): ; Return Value(s): Control Id on success, 0 on failure ; Author(s): ;=============================================================================== Func _GetDlgCtrlID($hwnd) $ID = DllCall('user32.dll', 'int', 'GetDlgCtrlID', 'hwnd', $hwnd) if IsArray ($ID) Then Return $ID[0] Return 0 EndFunc ;==>GetDlgCtrlID So long. Regards, [indent]ElTorro[/indent][font="Book"] Decide, Commit, Achieve[/font]_ConfigIO.au3Language Translation --uses Google(tm) MsgBox Move XML wrapper UDF XML2TreeView Zip functionality Split your GUI Save Print ScreenZipPluginEdit In Place listviewSome of my scripts on Google code Link to comment Share on other sites More sharing options...
jimlee Posted May 17, 2007 Share Posted May 17, 2007 But I don't have Control Handle So How should I get Control Handle? Thank you!! If you have hwnd then you can use this code: ;=============================================================================== ; Function Name: GetDlgCtrlID ; Description: Get CtrlId from Handle ; Parameter(s): $hwnd Handle of control ; Requirement(s): ; Return Value(s): Control Id on success, 0 on failure ; Author(s): ;=============================================================================== Func _GetDlgCtrlID($hwnd) $ID = DllCall('user32.dll', 'int', 'GetDlgCtrlID', 'hwnd', $hwnd) if IsArray ($ID) Then Return $ID[0] Return 0 EndFunc ;==>GetDlgCtrlID So long. Link to comment Share on other sites More sharing options...
eltorro Posted May 23, 2007 Share Posted May 23, 2007 maybe this will help?Classname from position$hwnd = ControlGetHandle ( "title", "text", controlID ) ;classname will work_GetDlgCtrlID($hwnd) Regards, [indent]ElTorro[/indent][font="Book"] Decide, Commit, Achieve[/font]_ConfigIO.au3Language Translation --uses Google(tm) MsgBox Move XML wrapper UDF XML2TreeView Zip functionality Split your GUI Save Print ScreenZipPluginEdit In Place listviewSome of my scripts on Google code 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