AutoIt: Activate and select the context menu of elements in ControlTreeView

I want to do an unattended installation using AutoIt. I cannot activate and select the item menu in the "select features" step. I can select any item in the tree. For this, I use the function

ControlTreeView($windowId, "", $h_tree, "Select", "#2") 

How to activate and select the menu items in ControlTreeView?

alt text

+4
source share
3 answers

You can see the answer to the question on the website http://forum.oszone.net/thread-146460.html

 #include <GuiMenu.au3> #include <GuiTreeView.au3> #Include <SendMessage.au3> #Include <WindowsConstants.au3> $WinTitle= "1: 8.1" $WinText = "  " WinWait($WinTitle, $WinText) ;         $hDTCtrl = ControlGetHandle($WinTitle, "", "SysTreeView321") $hDTItem = _GUICtrlTreeView_FindItem($hDTCtrl, " ") $hDTIt_1 = _GUICtrlTreeView_FindItem($hDTCtrl, "", False, $hDTItem) ;   WinActivate($WinTitle, $WinText) WinWaitActive($WinTitle, $WinText) ;      _GUICtrlTreeView_SelectItem($hDTCtrl, $hDTIt_1, $TVGN_FIRSTVISIBLE) _GUICtrlTreeView_ClickItem ($hDTCtrl, $hDTIt_1, "left", True) ;    $aRect = _GUICtrlTreeView_DisplayRect($hDTCtrl, $hDTIt_1, True) ControlClick($WinTitle, $WinText, $hDTCtrl, "left", 1, $aRect[0]-10, $aRect[1]+5) WinWait("[CLASS:#32768]") ;      $hWnd = WinGetHandle("[CLASS:#32768]") $hMenu = _SendMessage($hWnd, $MN_GETHMENU, 0, 0) $aRect = _GUICtrlMenu_GetItemRect($hWnd, $hMenu, 0) MouseClick("left", $aRect[0]+20, $aRect[1]+15, 1, 1) 
+1
source

You can do this using the keyboard.

I have done this in the past with

 send("{down}{space}{down}{down}{enter}") 

combination. I know that this is not the best way to do this, but it will work.

+2
source

@ alexey.chumagin the embed code is not complete (missing missing). And here:

 #include <GuiMenu.au3> #include <GuiTreeView.au3> #Include <SendMessage.au3> #Include <WindowsConstants.au3> $WinTitle= "1: 8.1" $WinText = "  " WinWait($WinTitle, $WinText) ;         $hDTCtrl = ControlGetHandle($WinTitle, "", "SysTreeView321") $hDTItem = _GUICtrlTreeView_FindItem($hDTCtrl, " ") $hDTIt_1 = _GUICtrlTreeView_FindItem($hDTCtrl, "", False, $hDTItem) ;   WinActivate($WinTitle, $WinText) WinWaitActive($WinTitle, $WinText) ;      _GUICtrlTreeView_SelectItem($hDTCtrl, $hDTIt_1, $TVGN_FIRSTVISIBLE) _GUICtrlTreeView_ClickItem ($hDTCtrl, $hDTIt_1, "left", True) ;    $aRect = _GUICtrlTreeView_DisplayRect($hDTCtrl, $hDTIt_1, True) ControlClick($WinTitle, $WinText, $hDTCtrl, "left", 1, $aRect[0]-10, $aRect[1]+5) WinWait("[CLASS:#32768]") ;      $hWnd = WinGetHandle("[CLASS:#32768]") $hMenu = _SendMessage($hWnd, $MN_GETHMENU, 0, 0) $aRect = _GUICtrlMenu_GetItemRect($hWnd, $hMenu, 0) MouseClick("left", $aRect[0]+20, $aRect[1]+15, 1, 1) 

A little explanation:

 WinWait("[CLASS:#32768]") $hWnd = WinGetHandle("[CLASS:#32768]") 

This is the code in which the context menu handle is received. #32768 is the name of a reserved system class that denotes a menu ( link here ).

0
source

All Articles