apr1985 Posted April 12, 2012 Share Posted April 12, 2012 Hello.I am looking to check some boxes on a TreeView, and was wondering if there is away to pattern match in the path, as this is different on different OS's.e.g.Pre-Vista tree:-My Computer -Coll on 'viper' (V:\) -Box1Post Vista tree:-Computer -Coll (\\viper) (V:\) -Box1At the moment I have to detect the OS and then run a different ControlTreeView command,e.g.ControlTreeView("Title","text","[CLASS:SysTreeView32; INSTANCE:1]","check","My Computer|Coll on 'viper' (V:\)|Box1") orControlTreeView("Title","text","[CLASS:SysTreeView32; INSTANCE:1]","check","Computer|Coll (\\viper) (V:\)|Box1") Is there away fo me to be able to pattern match so that I can just write a single command which will work in either case?e.g.ControlTreeView("Title","text","[CLASS:SysTreeView32; INSTANCE:1]","check","*Computer|Coll * viper * (V:\)|Box1") I am currently using Opt("WinTitleMatchMode", 2).Any help appriciated.Adam Link to comment Share on other sites More sharing options...
czardas Posted April 12, 2012 Share Posted April 12, 2012 (edited) You should use regular expressions.for pattern matching. I'm not really sure what patterns you need to match from reading the first post. Edited April 12, 2012 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
apr1985 Posted April 12, 2012 Author Share Posted April 12, 2012 Cheers for the reply. What I am looking at matching is the path down the tree. i.e. My Computer|Coll on 'viper' (V:)|Box1 or Computer|Coll (viper) (V:)|Box1 Usually to match either of these paths the standard wildcard character * could be used *Computer|Coll * (V:)|Box1 but this doesnt seem to work in autoit I want to be match either path and check Box1 with a single ControlTreeView command. Link to comment Share on other sites More sharing options...
czardas Posted April 12, 2012 Share Posted April 12, 2012 Looking at that it seems you only need to match brackets. If there is more than one set of brackets in the string then it is the 1st example, otherwise it will be the second. If this is the case then you can even use StringInStr. If StringInStr ( "Computer|Coll (viper) (V:)|Box1", "(", 0, 2) Then MsgBox(0, "Identity", "Post Vista") operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Spiff59 Posted April 12, 2012 Share Posted April 12, 2012 I don't think you have any option of embedding "or" logic into the ControlTreeView() call itself, so this is probably as simple as you can make it: If OS bla bla bla Then $sTreeMask = "My Computer|Coll on 'viper' (V:)" Else $sTreeMask = "Computer|Coll (viper) (V:)" EndIf ControlTreeView("Title","text","[CLASS:SysTreeView32; INSTANCE:1]","check", $sTreeMask & "|Box1") Link to comment Share on other sites More sharing options...
czardas Posted April 12, 2012 Share Posted April 12, 2012 (edited) I haven't done much with TreeView, but generally there is not much in the way of built in logic in AutoIt GUI controls. Some controls have flags which can be set for various types of behaviour. For something like this you have to write the code yourself. Of course some controls have more features than others. Edited April 12, 2012 by czardas operator64 ArrayWorkshop 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