Jump to content

Globbing/Pattern matching controltreeview


Recommended Posts

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

Link to comment
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.

Link to comment
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")
Link to comment
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")
Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...