Administrators Jon Posted March 17, 2007 Administrators Share Posted March 17, 2007 As part of the control/window code rewrite I want to improve how Autoit references windows and controls. Once we identify a window we can grab it's HWND handle - which is great. But finding the correct window/control in the first place can be tricky. Currently we have these ways of identifying windows: - By title/text (simple text and also with "RegExp=") - By classname ("classname=") And for controls: - By simple text caption - By a combination of classname and instance (referred to in AutoIt as ClassNameNN) - By control ID (used to be the best method, but less useful now that .NET framework breaks it) This works pretty well, but it has some flaws: - Inconsistant between identifying controls and windows, especially those with a classname. After all a control IS a window so this is odd. - If you open 3 identical windows there is no way to easily identify the 1st, 2nd, 3rd. You always get the first. (WinList wrangling required). I want to implement a single identification mechanism for windows and controls. But I don't want to break existing stuff, and I'm NOT keen on adding another Opt() function to switch. So I need some ideas. I'm thinking something like this: [title="...", regexptitle="...", class="...", instance="..."] So, to reference the 3rd new notepad window you could do [title="Untitled", instance="3"] or [class="Notepad", instance="3"] This would be the same for controls. A previous ClassNameNN of "Button123" would be: [class="Button", instance="123"] This would be used as the "Title" parameter of a Win...() function or as the "ClassNameNN" parameter of a Control...() function. Do you think it needs to be made more obvious (and less likely to be a real window name) like: au3info[title="", class=""] or [[title=""]] or [[[title=""]]] Or is it too unwieldy and it's fairly unlikely that we would get a clash anyway? (Don't want to rely on the WinTitleMatchMode thing) Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
Zedna Posted March 17, 2007 Share Posted March 17, 2007 (edited) Or is it too unwieldy and it's fairly unlikely that we would get a clash anyway? (Don't want to rely on the WinTitleMatchMode thing)I think this your new way should work only with WinTitleMatchMode = 4 (or maybe 5?)Most of users will be using Mode 1 anyway and more experienced users have no problem to use Mode 4 nowso it will be in consistence with previous logic in the future. Edited March 17, 2007 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Administrators Jon Posted March 17, 2007 Author Administrators Share Posted March 17, 2007 It doesn't make sense for windows to only use it when in matchmode 4 and controls to use it all the time though (again, inconsistancy). It should be fairly easy to check that the title begins and ends with [ ] and that it contains correct formatting. The only risk is if you need to identify a window with the exact same title, but then you could do that with [title="really unlikely title"] so not much a problem now that I think about it. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
Zedna Posted March 17, 2007 Share Posted March 17, 2007 It doesn't make sense for windows to only use it when in matchmode 4 and controls to use it all the time though (again, inconsistancy). It should be fairly easy to check that the title begins and ends with [ ] and that it contains correct formatting. The only risk is if you need to identify a window with the exact same title, but then you could do that with [title="really unlikely title"] so not much a problem now that I think about it. Yes you are right Jon. Your arguments are clear to me now and I agree. By the way: Thanks for neverending development of AutoIt guys Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
quaizywabbit Posted March 17, 2007 Share Posted March 17, 2007 for controls you could have ControlGetHandle() accept an array of either a pt or rect in client coords [u]Do more with pre-existing apps![/u]ANYGUIv2.8 Link to comment Share on other sites More sharing options...
Administrators Jon Posted March 18, 2007 Author Administrators Share Posted March 18, 2007 [title="...", regexptitle="...", class="...", instance="..."]Hmm, I forgot that the quotes would cause issues - don't want to make it annoying by having to do double quotes or swap between single and double ones. WinWait("[class=""myclass""]") or WinWait("[class='myclass']") are both a little fiddly and a quote accident waiting to happen. Maybe just: WinWait("[title:My Long Title; class:myclass; instance:3]") Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
Administrators Jon Posted March 18, 2007 Author Administrators Share Posted March 18, 2007 Maybe just: WinWait("[title:My Long Title; class:myclass; instance:3]")Got this working quite well locally on windows. Need to port it to the controls too and then some testing needed Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
Administrators Jon Posted March 18, 2007 Author Administrators Share Posted March 18, 2007 Uploaded test versions of just AutoIt3.exe and Au3Info.exe to http://www.autoitscript.com/autoit3/files/beta/autoit/Both windows and controls accept descriptions in the form "[PROPERTY:value; PROPERTY2:value2]"Windows have the properties:classtitleinstancelastactiveregexptitleControls have:classinstanceclassnn (legacy testing)idtextExample of Notepad text:ControlSetText("Untitled -", "", "[class:Edit]", "New Text Here" ) oÝ÷ ØZ+¶¶ÙèµêZw§v-Ù^v«¨µIíÙ^v«¨¶)í æN׫jëh×6 ControlSetText("[title:Untitled; instance:2]", "", "[class:Edit]", "New Text Here" )If you want to include ; : [ ] in the actual value of a property then double it up"[title:This is single colon::did you see it?]"It seems fairly longwinded but it's fine in conjunction with ControlGetHandle and WinGetHandle. And existing simple titles are still there - this is just when you need to more accurately specifiy a particular window/control. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ 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