Sign in to follow this  
Followers 0
Expansion

How do I select a specific path in SysTreeView32?

11 posts in this topic

I'm writing a script that monitors an application for child SysTreeView32 windows.

When it detects such a window, I want it to select a folder in the Tree View, according to a path that I specify in the script.

(ex. C:\\Files\test\)

How can I select the folder in the Tree View, according to a specified path?

Also, do you have any idea whether is possible to do the same thing with a DirectUIHWND window?

Share this post


Link to post
Share on other sites



How can I select the folder in the Tree View, according to a specified path?

Not directly. Take a look at ControlTreeView() how to obtain Treeview Info. You have to fetch the treeviews item text and loop through the results until the item matching your definition is selected (GetItemCount > "GetText", "item" > "Expand", "item" > GetItemCount .... > "Select", "item").

Also, do you have any idea whether is possible to do the same thing with a DirectUIHWND window?

From a theoretical standpoint... yes. From a practical standpoint... I don't know how :), those controls are real buggers.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

thank you. I've managed to write that function.

But, I'm facing a new problem. I can't find the handle to the SysTreeView.

#include <GUIConstantsEx.au3>
#include <TreeviewConstants.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#Include <GuiButton.au3>

$hwnd=HWND(0x000B0884) ;handle for the application window

$treeview_hwnd=ControlGetHandle ($hwnd,"",100) ;100= controlID
If @error Then
    MsgBox(4096, "Error", "Could not find the correct window")
Else

MsgBox(4096, "handle is", $treeview_hwnd)
EndIf

In fact, I can't find child windows with ControlGetHandle if I'm passing the handle(for the main application) instead of the title of the SysTreeView(which, actually has no title).

How should I call ControlGetHandle?

Edited by Expansion

Share this post


Link to post
Share on other sites

First please keep this from the help-file in mind (which is true for all standard Treeview / Listview controls):

"As AutoIt is a 32-bit application some commands are not available when referencing a 64-bit application as Explorer when running on 64-bit Windows."

That means if your target app is 32bit the script also has to be complied as 32bit, if the target app is 64bit the script also has to be.

Then you have to search for the control handle of the Treeview. These are generated dynamically and normally change on every start of the program. To do so I would recommend the excellent by Ascend4nt.

Share this post


Link to post
Share on other sites

Luckly I was running both of them on 32bit, but it's good to know, because I'm planning to write some scripts for a few 64bit apps, too.

I've discovered my problem. SysTreeView32 was not a direct child window, but a descendant window.

So, _EnumChildWindows should be the solution for me, right?

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I bumped into another problem, that I did not consider in the first place.

The script that I'm writing monitors for the creation of a specific TreeView, and selects a folder based on

a number that is incremented.

For example, first time when it detects the TreeView it should select "C:\test\1".

Second time, "C:\test\2", third time "C:\test\3" and so on.

The problem is that it should stop detecting the same TreeView, otherwise it would keep on

creating and selecting multiple folders for a single TreeView detection.

IMHO, there are 3 options:

1) based on comparing with previous handle, but there might be a very small possibility that the

TreeView receives the same handle.

2) waiting for me to click on the OK button from the Dialog Window that contains the TreeView

3) other ideas, if there are

I'd go for number 2), but I have no clue on how to intercept a buttonclick[when you have the button handle and controlID],

or whether if it's possible, or simple enough.

Edited by Expansion

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

Wow, that is perfect. Thank you.

Share this post


Link to post
Share on other sites

Is there a simple way to control these type of dialog windows?

Posted Image

Or I'd have to improvise something? ComboBox+ListView get/check

If so, any ideas? I'm asking because, most of the time, I come up with complex solutions.

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

File name: is an Edit control which you can set with ControlSetText() (or controlsend() / send(), but I would always first try ControlSetText() as it is much more reliable).

To "browse" to a path, ControlSetText() the path to the edit control (edit1 ?) and ControlSend "Enter" to the edit control.

To save to a certain filename, just copy the full-path (location + name) to the edit control via ControlSetText() and controlclick "Save" (button1 ?).

Edited by KaFu

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