Jump to content

Right Clicking on a TreeView node


matb
 Share

Recommended Posts

Hello all,

I'm currently evaluating AutoIt as a means of automating some software tests. What I need to be able to do is to right-click a node in the tree-structure in the MMC 3.0 console. Let's use the "Computer Management" system tool under Control Panel->Administrative Tools for this example.

I have found it to be very easy to expand and select nodes with AutoIt using code like this:

AutoItSetOption ( "WinTitleMatchMode", 4)

WinActivate ( "[REGEXPTITLE:Computer Management.*]")

ControlTreeView ( "Computer Management", "", 12785, "Expand", "Computer Management (Local)|System Tools" )
ControlTreeView ( "Computer Management", "", 12785, "Expand", "Computer Management (Local)|System Tools|Event Viewer" )
ControlTreeView ( "Computer Management", "", 12785, "Expand", "Computer Management (Local)|System Tools|Event Viewer|Security" )

ControlTreeView ( "Computer Management", "", 12785, "Select", "Computer Management (Local)|System Tools|Event Viewer|Security" )

However, I have not found an easy way to right click on a node (like the Security node in this example).

The following statement doesn't seem to work:

ControlClick ( "Computer Management", "", 12785, "right")

I've had no success adding x,y coordinates to the ControlClick method like this either:

$windowHandle = WinGetHandle("[REGEXPTITLE:Computer Management.*]")
$treeHandle = ControlGetHandle($windowHandle, "", "SysTreeView321")
$securityHandle = _GUICtrlTreeView_FindItem($treeHandle, "Security", True, _GUICtrlTreeView_GetFirstItem($treeHandle))
$securityRect = _GUICtrlTreeView_DisplayRect($treeHandle, $securityHandle, True)
$retVal = ControlClick ( "Computer Management", "", 12785, "right", 1, $securityRect[0]+5, $securityRect[1]+5)

The only way I've been able to right click anywhere on the tree control is by calculating some x,y coordinates and moving the mouse there before right clicking.

My question is this: Is there an easy way with AutoIt to right click on the node in the tree control without doing some ugly screen-coordinate calculations and movement of the mouse?

Thanks in advance

Link to comment
Share on other sites

If you are sure that your code works correctly and coordinates from _GUICtrlTreeView_DisplayRect are ok, try doing ControlFocus() before ControlClick. Also, you can simply send SHIFT+F10 when you have an item selected.

"be smart, drink your wine"

Link to comment
Share on other sites

Also, you can simply send SHIFT+F10 when you have an item selected.

That might be sufficient. Thanks :D

I would still like to know if there is a way of doing it without using coordinates or hot-keys. Seems like generating right clicks on a TreeView node would be a pretty basic & useful feature.

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