kanegr has asked for the wisdom of the Perl Monks concerning the following question:

I know you can access an open windows program through the win32 api and i've heard you can traverse a tree view in the windows program but haven't found any good examples. Does anyone know how to do this? Preferably reading and writing to the nodes of the systreeview32 contained in the program
  • Comment on traverse tree view and set the contents

Replies are listed 'Best First'.
Re: traverse tree view and set the contents
by Corion (Patriarch) on Dec 23, 2008 at 22:39 UTC

    If you were told this, you were misled. You can interact with any Win32 program through Win32::GuiTest, if that's what you want, but you're basically restricted to reading some on-screen text and sending keystrokes or mouse clicks.

    You can also write your own Explorer Namespace Extension, which can provide something like the Windows "Desktop" namespace, or the "Mobile Devices" namespace of ActiveSync. But that cannot be handled specific to a single program but affects the complete login session of the user. Also, Perl is not very well suited to such tasks, as such a task has to be written as a loadable module and not as a program like perl.exe.

      no it is quite possible to actually get the individual components of windows program through the api. For instance I can get the handle to the treeview of a windows explorer.

        That's true, and that's what Win32::GuiTest gives you. But it's not (easily) possible to change the contents of a treeview, because you'll run into memory allocation problems.

        You might be able to use that handle to make a Win32::GUI::TreeView object like this
        use Win32::GUI; my $tree = bless( { '-type' => 0, '-name' => 'Guessing', '-handle' => $treehandle, '-accel' => 0 }, 'Win32::GUI::TreeView' )
        then maybe you can set/change data easier