Sign in to follow this  
Followers 0
MZXPTLK

Treeview

14 posts in this topic

Hi,

I want to control a treeview (SysTreeView32) of a third party product with AutoIt.

In the treeview a node should be selected an expanded.

Any ideas?

Manfred

Share this post


Link to post
Share on other sites



Helpfile, that's why it's there. Look at the Control* functions.

Good idea, but I only found things about controlling treeviews that are created with AutoIt's TreeViewItemControl ...

Share this post


Link to post
Share on other sites

Did you look at the Control* functions? ControlClick, ControlSend() etc. Use the Window Info Tool to find out the details about the treeview and you should be good from there.

Share this post


Link to post
Share on other sites

Did you look at the Control* functions? ControlClick, ControlSend() etc. Use the Window Info Tool to find out the details about the treeview and you should be good from there.

Yes, I know this functions.

But I want to get control over the treeview and its nodes, and not only use sendkeys.

There is a DLL called AutoItTreeViewExtension.dll, to use for that.

But I didnot get it to work, and thought there are other possibilities of controlling a treeview.

Share this post


Link to post
Share on other sites

I wouldn't know why it would matter what way you control it but to each his own. I think this was asked a while back (maybe a week or two) so a good search should turn up some results. Why don't you post the code you tried with the dll and maybe someone can help you fix it.

Share this post


Link to post
Share on other sites

I wouldn't know why it would matter what way you control it but to each his own.

Ok, let me tell you what I want to do:

There is a computer administration program called 'Hyena'.

Hyena shows a list of computer names (hundreds) in a treeview control.

Now I have another program that gives me a computer name maybe 'PC100'.

So, what I want to do, is to jump to Hyena, find the computer name 'PC100' in the treeview, select the its node and expand it.

I don't think you can manage this using ControlClick and ControlSend.

Maybe I'm wrong, but I'm always open for good suggestions :P

Share this post


Link to post
Share on other sites

Hm, I haven't personally tried this but could you possibly get the text of the node and click that way? I don't really work with treeviews much so I'm just theorizing here.

Share this post


Link to post
Share on other sites

Hm, I haven't personally tried this but could you possibly get the text of the node and click that way? I don't really work with treeviews much so I'm just theorizing here.

Thank you for the moment, i will test that ...

Maybe there are more ideas?

Share this post


Link to post
Share on other sites

Only other thing I could really think of is basically the same, just get the PC name however you do it and use that as the text parameter in ControlClick() so that it should open the node.

Share this post


Link to post
Share on other sites

I found the solution.

It's easy: #include <GuiTreeView.au3>

There are all necessary functions I need.

Manfred

Share this post


Link to post
Share on other sites

I found the solution.

It's easy: #include <GuiTreeView.au3>

There are all necessary functions I need.

Manfred

Yes you are right - that's the right solution.

For simple treeview operations (even in external applications) you can use also ControlTreeView()

Share this post


Link to post
Share on other sites

I was able to get Hyena to navigate with the following code:

I haven't been able to get the right-click menu selection to work yet.

Let me know if this helps

#include <GuiTreeView.au3>

WinWait('Hyena v7.3','')
If Not WinActive('Hyena v7.3','') Then WinActivate('Hyena v7.3','')
WinWaitActive('Hyena v7.3','')

$hTreeView = ControlGetHandle('Hyena v7.3', '', 'SysTreeView321')

$NavigationList = StringSplit('Enterprise,Networks,Microsoft Windows Network,VarianStyles', ',')    ;Expand the Tree to your Domain
For $i = 1 to $NavigationList[0]
    Navigate($hTreeView, $NavigationList[$i])
Next

Navigate($hTreeView, 'MAIL') ;Now navigate to the computer that your other program gives you

;Now do something on that computer...Get User Rights
$hItemFound = _GUICtrlTreeView_FindItem($hTreeView, 'User Rights')
    If $hItemFound Then
        _GUICtrlTreeView_ClickItem($hTreeView, $hItemFound, 'left', True, 2)
    Else
        Exit
EndIf

Func Navigate($Handle, $Control)
    $hItemFound = _GUICtrlTreeView_FindItem($Handle, $Control)
    If $hItemFound Then
        _GUICtrlTreeView_Expand($Handle, $hItemFound, True)
        _GUICtrlTreeView_ClickItem($Handle, $hItemFound, 'left', True, 1)
    Else
        msgbox(0, 'Error', 'Cannot Find ' & $Control)
    EndIf
EndFunc

Share this post


Link to post
Share on other sites

I was able to get Hyena to navigate with the following code:

I haven't been able to get the right-click menu selection to work yet.

Let me know if this helps

Sorry for answering late ...

First, thank you very much for your efforts.

I tested the code, but I could only access nodes that are visible.

That works indead.

But, if a node is not visible, then _GUICtrlTreeView_FindItem return 0.

I tried to use _GUICtrlTreeView_EnsureVisible, but without success.

Perhaps you have an idea, Varian?

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