Jump to content
MartyCologne

TreeView + GetText: only number of items is found

Recommended Posts

MartyCologne

Hi,

I am new to AutoIt and am trying my best to improve my skills and also one day hope to return some support to others here.

I am currently struggling with an external application that I need to control.

 

So far, I have been able to do some very basic stuff, e.g. launch it, wait for its main window to show up, select a menu item and click it, wait for another window to show up.

This second window contains a large treeview control. It has many collapsed items with many sub-items, also collapsed, and then many entries. I was able to identify the control to get its window handle, class name, ID and I was also able to get the correct amount of items and sub-items.

 

The point where I am stuck now is to search for a particular item, click on that item to both select it and return from the treeview window to the main window. Unfortunately, I cannot post an image of the treeview here because I use it at work and atm I am using my private Linux computer on which i cannot use autoit anyway.

 

I am stuck because I do not get any string results, either I get 0 or no entry at all.

 

As I am really quite new I might already be stuck deciding what function I should use to get the text items. Am I right to say that there are _GUI functions that are supposed to work only with autoit-built GUIs, or would all functions provided by autoit work both for internal and external GUIs? How about the admin-issue - would this cure my issue, if I ran autoit as admin (not sure why I get correct results for the number of items though)?

Perhaps you can point me to a neat and fool-proof tutorial on how to setup autoit to properly find text in a treeview.

 

Thanks a lot for your help in advance! It is highly appreciated.

Marty.

Share this post


Link to post
Share on other sites
Earthshine

What application, exactly, are you trying to automate this tree control?  If you were trying to automate windows explorer been good luck. It is extremely unwieldy 


My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites
Zedna

AutoIt's TreeView functions work only with standard TreeView  controls with SysTreeView32 ClassName.

 

What's the ClassName of your TreeView control?

Share this post


Link to post
Share on other sites
MartyCologne

These are the details I get from autoit:

>>>> Window <<<<

Title:      Testcases

Class:    WindowsForms10.Window.8.app.0.141b42a_r14_ad1

Position:              2888, 166

Size:      553, 636

Style:    0x16CF0000

ExStyle: 0x00050100

Handle: 0x0000000000560A88

 

>>>> Control <<<<

Class:    WindowsForms10.SysTreeView32.app.0.141b42a_r14_ad1

Instance:             1

ClassnameNN:  WindowsForms10.SysTreeView32.app.0.141b42a_r14_ad11

Name:  treOverview

Advanced (Class):            [NAME:treOverview]

ID:          527098

Text:    

Position:              7, 48

Size:      525, 543

ControlClick Coords:       265, 247

Style:    0x56310207

ExStyle: 0x00000000

Handle: 0x0000000000080AFA

 

>>>> Mouse <<<<

Position:              3168, 492

Cursor ID:           0

Color:    0x3A0000

 

>>>> StatusBar <<<<

 

>>>> ToolsBar <<<<

 

>>>> Visible Text <<<<

ToolStrip1

Overview

 

@Earthshine

I am sorry I cannot post the original application window content due to restrictions of my company. It is no standard Windows application (no Explorer, no Excel, no part of Office). It is a non-AutoIt application (i.e. no AutoIt elements were used to create the window and the treeview list).

Would it be required to unfold all collapsed parts before searching for a particular string? But atm. I do not even get a single string.

Share this post


Link to post
Share on other sites
Earthshine

Well can you post your code that isn’t working minus anything sensitive 


My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites
MartyCologne
Posted (edited)

OK, I was finally able to make some progress here.

;Do
   ; Check if application is running, if not, run it with current request.
[THIS WORKS]

   ; Now that application is running, open the required window
[THIS WORKS]

   ; Get current handle of window
   $hWnd = WinWaitActive("[CLASS:WindowsForms10.Window.8.app.0.141b42a_r14_ad1; TITLE:Testcases; INSTANCE:1]")

   ; Get current handle of the Tree Overview Control
   $hMenu = ControlGethandle($hWnd,"","[CLASS:WindowsForms10.SysTreeView32.app.0.141b42a_r14_ad1;NAME:treOverview; INSTANCE:1]")

   ; Get current ID of the Tree Overview Control.
   $myID = _WinAPI_GetDlgCtrlID($hMenu)

   ; Enter the string to be searched
[THIS WORKS]

   ; Reactivate Window again, in case it is covered by other windows
[THIS WORKS]

   $location = _TreeViewSearch( "Testcases", "", $hMenu, $testcaseID, "#0" ) ; ==> This is a function I've found in autoit forum examples.
   ControlTreeView( "Testcases", "", $myID, "Select", $location )

[THIS WORKS]

   ;controlclick("Testcases","",$location) ==> does not work
   
;until @error=1

 

It is working to open the required application.

It is working to make autoit open the required window.

It is working to enter a search string and find it in the treeview.

Now what does not work:

The entry is found OK and it is selected. "Selected" here means that the entry is highlighted but not clicked.

I cannot send a mouse click to the item.

The do... until loop does not work. I cannot exit the loop by checking @error=1 which is supposed to be set when the "Cancel" button in the inputbox command used to enter the search string is clicked.

 

What should I do?

I am having a hard time to understand the "index reference" vs. "text index" etc. stuff.

From what I have learned so far, "index" is a string that looks like this: "#1 | #1 | 2"

But how do I found a numerical value of a entry in a treeview list that would be required to use command ControlClick? Is this correct at all?

I also do not understand the concept of _GUIxxx commands. I think that these can only be used for GUIs created using autoit itself. So it is not possible to use them for external windows controls. Why do I see so many examples in autoit forum that use _GUIxxx commands also for external windows controls, if this is not even supposed to work?

 

Thanks a lot for your help.

Marty

Edited by MartyCologne

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

×