Jump to content

Treeview item manipulation issues GUICtrlTreeView_SelectItem, ControlTreeView, windows 2008 server


Recommended Posts

Hi all,

I'm having trouble with just some basic treeview manipulation and I'm wondering if someone has run into this before? I'm just trying to find and select a specific item in a tree control.

I'm trying to just use the built in autoit functions but running into some weird issues. I'm hoping it's programmer errror. :P

1. A call to ControlTreeView with a "select" and named path works on Vista 32-bit, but not on Windwows 2008 64-bit edition.

2. _GUICtrlTreeView_FindItem crashes Microsoft managment Console on my 32-bit Vista machine, but I can't see why. I successfully maninpulate the treecontrol earlier with ControlTreeView so I've got the right handle. I thought that _GUICtrlTreeView_FindItem worked on already existing Treecontrols per another thread. I start up MMC and open up compmgmt.msc in the system32 directory.

I notice that there is a note about 64-bit operating systems in the help and that there might be issues with it, but I would think that

_GUICtrlTreeView_FindItem would work on Vista. Yes?

#include <GuiTreeView.au3>

#include <GuiConstantsEx.au3>

#include <WindowsConstants.au3>

$WindowHandle = WinGetHandle("Computer Management")

$treeviewRolesHandle = ControlGetHandle ( "Computer Management", "", "[iD:12785]")

ConsoleWrite('Window Handle ' & $WindowHandle & ' Tree view role handle' & $treeviewRolesHandle & @crlf)

$answer = ControlFocus("Computer Management", "", 12785)

Sleep(1000)

;Works on both platforms, but I notice that I need to expand each node.

;I just can't issue the last statment and ask to expand a child that's not visible yet.

ControlTreeView ("Computer Management", "", $treeviewRolesHandle, "Expand", "#0")

ControlTreeView ("Computer Management", "", $treeviewRolesHandle, "Expand", "#0|#0")

ControlTreeView ("Computer Management", "", $treeviewRolesHandle, "Expand", "#0|#0|#1")

Sleep(1000)

; WORKS on Vista 32-bit, but not on Windows 2008 64-bit

ControlTreeView ("Computer Management", "", $treeviewRolesHandle, "Select", "Computer Management (Local)|System Tools|Device Manager")

;Sleep(1000)

$unicode = _GUICtrlTreeView_GetUnicodeFormat($treeviewRolesHandle)

If $unicode = True then ConsoleWrite("Treecontrol is using unicode characters" & @crlf)

$hItem = _GUICtrlTreeView_FindItem( $treeviewRolesHandle, "Device Manager", True, 0 )

; The above Crashs MMC. in Vista 32-bit. Not sure why. scripted locked up until I end it, then continues. $hItem is 0 at that point.

ConsoleWrite('hitem ' & $hItem & ' Tree view role handle' & $treeviewRolesHandle & @crlf)

;_GUICtrlTreeView_SelectItem( $treeviewRolesHandle, $hItem )

; Obviously won't work if _GUICtrlTreeView_FindItem doesn't work.

Variable is called $treeviewRolesHandle above because eventually I'm trying to start up hyperV sessions via the Server Manager which is under the Roles Node.

Link to comment
Share on other sites

Found the answer to #1 myself. For some reason, AutoIT set up to run it's 32-bit version on Windows Server 2008. I thought it was supposed to auto detect this. Not sure why that is. I'm also not sure how to change it in the SciTE editor either. Anyone know? I looked all over for an option, but can't find it.

So I renamed the EXEs just to test and the TreeViewControl works now. Just see in the Program Files\AutoIT area and you'll see the 64bit and 32 bit versions.

This code helped me figure out what was going on. Almost all text matching was failing includine for Run() and ShellExecute().

ConsoleWrite("OS Version is " & @OSARCH & @CRLF)

ConsoleWrite("AutoIT 64bit Version Running? 1 if so -->" & @AutoItX64 & @CRLF)

The _GUITreeView_SelectItem still doesn't work, but at least I have another option.

Link to comment
Share on other sites

Looks like the version of AutoIT3 I have has a bug in the installation program. Version 3.3.0.0. It asks me if I want to use 64-bit tools at the install, but then it doesn't set up the SCiTE editor to invoke 64-bit version of AutoIT.exe. Perhaps it's because I'm installing SciTE after installing AutoIt. I'm not sure and will try to test if I have to do another install.

Anyway, the fix is still to manually set up the 64-bit version of the window info tool and AutoIT itself in the Program Files (X86)\AutoIT directory. I'm doing it with a copy and a rename so I've got the 32-bit, 64-bit and then the version invoked by the editor.

A number of commands that use text fail when using the 32 bit version. Run("msc") wont even work. The script will just sit there and hang waiting for the window to come up (due to a WinWaitActive call).

I haven't tested the beta version so I'm not sure if this is a problem there or not.

Rob

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...