Search code examples
autoit

AutoIt: Activate and choose elements context menu in ControlTreeView


I want to do automatic installation by AutoIt. I cant activate and choose elements menu on the "select features" step. I can choose any element in the "tree". For it I use the function

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

How to activate and choose the elements menu in ControlTreeView?

alt text


Solution

  • You can see answer on the question on the site 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)