Chris Posted October 24, 2008 Share Posted October 24, 2008 Hi, Are there any tricks I can use to identify a control (for use with the ControlXXX commands) when the CLASS and ID seem to be changing each time the application is run. It's a .NET app and I think the form is dynamically adding the controls... I was using an id like this: "[CLASS:WindowsForms10.BUTTON.app4; INSTANCE:1]" but when I run the program as different users, the app4 part changes (I've seen app4 and app5). I changed to using ID (eg "[iD:65432]") but the ID of the button changes every time the application runs (although I read in the forum or faq that the ID is supposedly the most reliable way of identifying a control). The button I want to activate has an image but no text, however fortunately it's our own application so I've worked around it by adding a tiny button (hidden behind the original one) which performs the same action and has text which I can use (So now I'm using "[TEXT:Blah]") to find the hidden button and I'm sending a message to that instead. Still I was wondering if anyone knows if there is a better way of doing it or of getting the .NET forms to generate a consistent id that is visible to AutoIt (I tried setting AccessibleName and properties like that but couldnt find them in the autoit info). cheers Link to comment Share on other sites More sharing options...
jvanegmond Posted October 24, 2008 Share Posted October 24, 2008 I've tried automating a .NET application but its control ID, classname or instance never changed. So I had to go with what you said in the first post, and hope I am doing it correctly.You can use a REGEXPCLASS to find the correct control you are looking for. It's useful to find a control by classname using a regular expression.$hWnd = WinGetHandle("[active]") $ControlClass = "[REGEXPCLASS:WindowsForms10\.BUTTON(.*)?; INSTANCE:1]" $ChWnd = ControlGetHandle($hWnd, "", $ControlClass)For more information, please look at:http://www.autoitscript.com/autoit3/docs/f...tringRegExp.htmhttp://www.autoitscript.com/autoit3/pcrepattern.htmlhttp://www.autoitscript.com/autoit3/docs/t...gexp/regexp.htmhttp://www.codeproject.com/KB/dotnet/regextutorial.aspx github.com/jvanegmond Link to comment Share on other sites More sharing options...
zfisherdrums Posted October 24, 2008 Share Posted October 24, 2008 If the developer gave the control a name at design-time, you can appropriate it via a WM_GETCONTROLNAME message. Look here for an example I ported on how to do this. Hope it helps; let me know if it doesn't.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