Jump to content

ControlTreeView function issue - (Moved)


Recommended Posts

I am working on a task using AutoIT tool where I need to traverse through the tree structure of the Computer Management to one of the services(in this case it is CDB Services) and verify  message in information levels for that service.

Tree view is as Computer Management tool -> Computer Management(Local)->System Tools->Event Viewer->Application and Services logs->CDB service

 

I am trying with ControlTreeView function with ‘Select’ / 'Expand' command in the script.

Script as follow:

ShellExecute("compmgmt.msc")

ControlTreeView ("Computer Management", "",12785, "Select", "Computer Management(Local)|System Tools|Event Viewer|Applications and Services Logs|CDB Services")

Above script is not working.

Can someone please help..

Link to comment
Share on other sites

  • Moderators

Moved to the appropriate forum, as the Developer General Discussion forum very clearly states:

Quote

General development and scripting discussions. If it's super geeky and you don't know where to put it - it's probably here.


Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums.

Moderation Team

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

This is working for me :

#RequireAdmin
#include <Constants.au3>

Opt ("MustDeclareVars", 1)

ShellExecute ("compmgmt.msc")
Local $hWnd = WinWaitActive ("[CLASS:MMCMainFrame]")
Local $hCtrl = ControlGetHandle ($hWnd, "", "SysTreeView321")
ControlTreeView ($hWnd, "", $hCtrl, "Expand", "#0|#0|#1")
Sleep (800)
ControlTreeView ($hWnd, "", $hCtrl, "Expand", "#0|#0|#1|#2")
Sleep (800)
ControlTreeView ($hWnd, "", $hCtrl, "Select", "#0|#0|#1|#2")
Sleep (800)
ControlTreeView ($hWnd, "", $hCtrl, "Select", "#0|#0|#1|#2|#2")

 

Link to comment
Share on other sites

Thanks for providing solutions using instances to traverse the tree structure and it is working fine.

I am trying to use labels instead of instances in control tree view but it is not working.

Below is the scripts

#RequireAdmin
#include <Constants.au3>
#include <GuiTreeView.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3>

Opt ("MustDeclareVars", 1)
ShellExecute ("compmgmt.msc")
Sleep(2000)
Local $hWnd =WinWaitActive ("[CLASS:MMCMainFrame]")
Local $hCtrl = ControlGetHandle ($hWnd, "", "SysTreeView321")
Sleep(2000)
ControlTreeView($hWnd, "", $hCtrl, "Expand", "Computer Management(Local)|System Tools|Event Viewer")
Sleep(2000)
ControlTreeView ($hWnd, "", $hCtrl, "Expand", "Computer Management(Local)|System Tools|Event Viewer|Applications and Services Logs")
Sleep(2000)
ControlTreeView ($hWnd, "", $hCtrl, "Select", "Computer Management(Local)|System Tools|Event Viewer|Applications and Services Logs")
Sleep(2000)
ControlTreeView ($hWnd, "", $hCtrl, "Select", "Computer Management(Local)|System Tools|Event Viewer|Applications and Services Logs|CDB Services")
Sleep(5000)
WinClose("Computer Management")

 

Could you please help me and let me know if I am doing it in a wrong way.

Thanks in advance for your help.

 

Link to comment
Share on other sites

I have a french OS.  So I cannot replicate your code.  This is the main reason why I decided to use indexes.  Also if you miss one single character, like a space or anything else, it will not work.  I believe it must be your case.  To solve your problem you could request commands of "GetText" to ensure you got the proper naming of each labels. Put the names in the console then copy/paste them in your code.  Should work...

Link to comment
Share on other sites

Thanks for your response.

I copied the path from visible text in AutoIt Window info and replaced '\' with '|' in then used in ControlTreeView command.

I also tried to display error after execution of below statement. It displayed error on the message box. 

ControlTreeView($hWnd, "", $hCtrl, "Expand", "Computer Management (Local)|System Tools|Event Viewer")
if @error Then
   MsgBox(4096, '', 'Error',2)
EndIf

Not able to find exact issue in the code.  Can you please let me know how we can debug code in autoIT. That will be a great help. 

Below is complete script:

#RequireAdmin
#include <Constants.au3>
#include <GuiTreeView.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <MsgBoxConstants.au3>
#include <Array.au3>

Opt ("MustDeclareVars", 1)
ShellExecute ("compmgmt.msc")
Sleep(2000)
Local $hWnd =WinWaitActive ("[CLASS:MMCMainFrame]")
Local $hCtrl = ControlGetHandle ($hWnd, "", "SysTreeView321")
Sleep(2000)

ControlTreeView($hWnd, "", $hCtrl, "Expand", "Computer Management (Local)|System Tools|Event Viewer")
if @error Then
   MsgBox(4096, '', 'Error',2)
EndIf

Sleep(2000)
ControlTreeView ($hWnd, "", $hCtrl, "Expand", "Computer Management (Local)|System Tools|Event Viewer|Applications and Services Logs")
Sleep(2000)
ControlTreeView ($hWnd, "", $hCtrl, "Select", "Computer Management (Local)|System Tools|Event Viewer|Applications and Services Logs")
Sleep(2000)
Local $sText = ControlTreeView ($hWnd, "", $hCtrl, "GetText", "Computer Management (Local)|System Tools|Event Viewer|Applications and Services Logs|CDB Services")
MsgBox(4096, '', $sText,2)
Sleep(5000)
WinClose("Computer Management")

 

Link to comment
Share on other sites

Apologies for posting script in plain text format. I will follow forum rule for posting the script. Thanks.

Actually, I need to verify if the CDB service is installed on the machine first.

If it is installed then I need to do validation on information messages under Level for CDB services.

As per my understanding index of CDB service can vary on machine to machine. If it is so then traversing tree structure using indexes will fail.

 

 

Link to comment
Share on other sites

I see.  Well I checked and got also problem using labels.  Solution, it must be runned x64.  See ControlView remarks :

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


 

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