Sign in to follow this  
Followers 0
apr1985

Globbing/Pattern matching controltreeview

6 posts in this topic

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:\)

-Box1

Post Vista tree:

-Computer

-Coll (\\viper) (V:\)

-Box1

At 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")

or

ControlTreeView("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

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by czardas

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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")

Share this post


Link to post
Share on other sites

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")

Share this post


Link to post
Share on other sites

#6 ·  Posted (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 by czardas

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0