Sign in to follow this  
Followers 0
jp10558

Accessing mmc.exe snapins

5 posts in this topic

So, I've been trying to automate setting some local group policies as part of some software installs. One major problem I've had is that there doesn't seem to be a way by default to pick out control IDs to send a click to in the gpedit snapin..

Has anyone used Auto3Lib which provides what seems to be a way to get info from treeviews to then send commands to specific ones? Any quick examples on how to do that?

Another thing that happens is certain programs as part of their install or activation use embedded websites. Is there a better way to access them (again, like control IDs) then using send tab and enter? Maybe a way to say look for buttons on this webform, and the one that matches submit send a click event to?

Share this post


Link to post
Share on other sites



Generally speaking, if the install uses an imbedded html display, then it's (most likely) some flavour of IE. Perhaps the IE COM calls would help?


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

Has anyone used Auto3Lib which provides what seems to be a way to get info from treeviews to then send commands to specific ones? Any quick examples on how to do that?

Here is an example (mostly from the Auto3Lib TreeView demo) of how to read the GPEdit TreeView:

#include <A3LTreeView.au3>

Run("MMC.exe C:\Windows\System32\GPEdit.msc")
_WinWaitActive("Group Policy")

$hTree = ControlGetHandle("Group Policy", "", "SysTreeView321")
if @Error then _ShowError("Unable to find TreeView")

ShowTree()
ShowNodes()

; =================================================================================================
; Show TreeView details
; =================================================================================================
Func ShowTree()
  Local $hRoot

  $hRoot = _TreeView_GetRoot($hTree)
  ConsoleWrite("Tree Handle ............: " & $hTree                                           & @CR)
  ConsoleWrite("Tree Item Count ........: " & _TreeView_GetCount       ($hTree)                & @CR)
  ConsoleWrite("Tree Max Visible Count .: " & _TreeView_GetVisibleCount($hTree)                & @CR)
  ConsoleWrite("Tree Root ..............: " & $hRoot                                           & @CR)
  ConsoleWrite("Tree First Visible .....: " & _TreeView_GetFirstVisible($hTree)                & @CR)
  ConsoleWrite("Tree Selection .........: " & _TreeView_GetSelection   ($hTree)                & @CR)
  ConsoleWrite("Tree Drop Hilite .......: " & _TreeView_GetDropHilite  ($hTree)                & @CR)
  ConsoleWrite("Tree Image List Normal .: " & _TreeView_GetImageList   ($hTree, $TVSIL_NORMAL) & @CR)
  ConsoleWrite("Tree Image List State ..: " & _TreeView_GetImageList   ($hTree, $TVSIL_STATE ) & @CR)
  ConsoleWrite("Tree Indent ............: " & _TreeView_GetIndent      ($hTree)                & @CR)
  ConsoleWrite(@CR)
EndFunc

; =================================================================================================
; Show TreeView node details
; =================================================================================================
Func ShowNodes()
  Local $iX1, $iY1
  Local $iX2, $iY2
  Local $hNext
  Local $rRect

  $hNext = _TreeView_GetRoot($hTree)
  $rRect = _DllStructCreate($RECT)
  while $hNext <> 0
    $rRect = _TreeView_GetItemRect($hTree, $hNext, True)
    $iX1   = _DllStructGetData($rRect, $RECT_LEFT  )
    $iY1   = _DllStructGetData($rRect, $RECT_TOP   )
    $iX2   = _DllStructGetData($rRect, $RECT_RIGHT )
    $iY2   = _DllStructGetData($rRect, $RECT_BOTTOM)
    $rRect  = 0

    ConsoleWrite("Item ...................: " & $hNext                                     & @CR)
    ConsoleWrite("Item Parent ............: " & _TreeView_GetParent       ($hTree, $hNext) & @CR)
    ConsoleWrite("Item Previous ..........: " & _TreeView_GetPrev         ($hTree, $hNext) & @CR)
    ConsoleWrite("Item Has Children ......: " & _TreeView_GetChildren     ($hTree, $hNext) & @CR)
    ConsoleWrite("Item Child Count .......: " & _TreeView_GetCount        ($hTree, $hNext) & @CR)
    ConsoleWrite("Item First Child .......: " & _TreeView_GetFirstChild   ($hTree, $hNext) & @CR)
    ConsoleWrite("Item Prev Child ........: " & _TreeView_GetPrevChild    ($hTree, $hNext) & @CR)
    ConsoleWrite("Item Last Child ........: " & _TreeView_GetLastChild    ($hTree, $hNext) & @CR)
    ConsoleWrite("Item Next Visible ......: " & _TreeView_GetNextVisible  ($hTree, $hNext) & @CR)
    ConsoleWrite("Item Prev Visible ......: " & _TreeView_GetPrevVisible  ($hTree, $hNext) & @CR)
    ConsoleWrite("Item Index .............: " & _TreeView_GetIndex        ($hTree, $hNext) & @CR)
    ConsoleWrite("Item Is Bold ...........: " & _TreeView_GetBold         ($hTree, $hNext) & @CR)
    ConsoleWrite("Item Is Cut ............: " & _TreeView_GetCut          ($hTree, $hNext) & @CR)
    ConsoleWrite("Item Is Drop Target ....: " & _TreeView_GetDropHilited  ($hTree, $hNext) & @CR)
    ConsoleWrite("Item Is Expanded .......: " & _TreeView_GetExpanded     ($hTree, $hNext) & @CR)
    ConsoleWrite("Item Is Expanded Once ..: " & _TreeView_GetExpandedOnce ($hTree, $hNext) & @CR)
    ConsoleWrite("Item Is Focused ........: " & _TreeView_GetFocused      ($hTree, $hNext) & @CR)
    ConsoleWrite("Item Is Selected .......: " & _TreeView_GetSelected     ($hTree, $hNext) & @CR)
    ConsoleWrite("Item Is Visible ........: " & _TreeView_GetVisible      ($hTree, $hNext) & @CR)
    ConsoleWrite("Item Level .............: " & _TreeView_GetLevel        ($hTree, $hNext) & @CR)
    ConsoleWrite("Item Image Index .......: " & _TreeView_GetImageIndex   ($hTree, $hNext) & @CR)
    ConsoleWrite("Item State Index .......: " & _TreeView_GetStateIndex   ($hTree, $hNext) & @CR)
    ConsoleWrite("Item Overlay Index .....: " & _TreeView_GetOverlayIndex ($hTree, $hNext) & @CR)
    ConsoleWrite("Item Selected Index ....: " & _TreeView_GetSelectedIndex($hTree, $hNext) & @CR)
    ConsoleWrite("Item Rectangle .........: [" & $iX1 & ", " & $iY1 & ", " & $iX2 & ", " & $iY2 & "]"  & @CR)
    ConsoleWrite("Item Text ..............: " & _TreeView_GetText         ($hTree, $hNext) & @CR)
    ConsoleWrite(@CR)
    $hNext = _TreeView_GetNext($hTree, $hNext)
  wend
EndFunc

Auto3Lib: A library of over 1200 functions for AutoIt

Share this post


Link to post
Share on other sites

So if I know the item identifier from the console (is that inside AutoIt - the console, or is it like stdout?) can I send a click command? This may be over my head for now.

Share this post


Link to post
Share on other sites

So if I know the item identifier from the console (is that inside AutoIt - the console, or is it like stdout?) can I send a click command? This may be over my head for now.

You can use _TreeView_GetItemRect to get the rectangle where an item is and then use MouseClick to click within that rectangle to select the item.

Auto3Lib: A library of over 1200 functions for AutoIt

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
Sign in to follow this  
Followers 0