Jump to content

How to work with treeview?


Recommended Posts

I am trying to automate some task and I hit the wall, a TreeView.

How select an item in the treeview? For example, through script I've just added new item called "newItem". Now, I want to find and select this item. I tried

$n = ControlCommand("FACSys Desktop", "", "SysTreeView321", "SelectString", 'newItem')

It didn't work.

Thanks,

Link to comment
Share on other sites

Thanks for your response Kip.

For last couple of day I am not doing anything besides reading help files.

The problem is I am not trying to create new treeview control. I am trying to automate process of installing phonebooks in my FAX application at work. The process consists of pointing to source(database file), then new phonebook item is added to treeview control (this treeview is control in the FAX application that I am trying to automate). This new phonebook items would have generic names like noname01, noname02,...etc.

So I will repeat my question: How to find item in the treeview control named "noname01" and do right-mouse-click on it?

These are control information from AutoIt Widnow Info:

Control ID: 59648

ClassNameNN: SysTreeView321

In the help I found ControlListView. I need something like this for treeview. I played with ControlCommand, but it does not work.

Thanks,

Read the wonderfull help file that was installed with autoit.

User Defined Function > GuiTreeView Management

Link to comment
Share on other sites

$treeview is your treeview object

$Input is the item to search: noname01, etc.

#include <GuiTreeView.au3>
#include <Array.au3>

$Items = _GUICtrlTreeViewGetCount ($treeview) ;Count how many items there are
Dim $Count[$Items] ;Create a array with '$Items' elements

For $i = $Items to 1 step -1 ;Repeats the two following lines '$Items' times
$Text = _GUICtrlTreeViewGetText($treeview, $i) ;Recieve the text of item '$i'
_ArrayInsert( $Count,$i,$Text) ;Insert the text: '$Text' in the array
Next

$Pos = _ArraySearch ($Count, $Input, 0, 0, 0, True) ;Search in the array for your search term ($Input)
_GUICtrlTreeViewSetState($treeview, $Pos, $TVIS_SELECTED) ;Select the searched and founded item (you can change this in what you want)

I didn't tested it, but you should know now a little bit, how to go on.

Edited by kip
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...