Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/04/2021 in all areas

  1. ptrex

    Hex Editor COM Control

    HEX Editor COM Control You can find the HEX Editor GUI example based on this ActiveX control https://www.codeproject.com/Articles/1384/Hex-Editor-OCX-Control It was a challenge to make it all work, but due the Lars his bright solution the final piece of the puzzle was in place. See here where all the magic is happening ! I made 2 slight optimizations : 1. No need for an external VBScript 2. No need to register the OCX control on Windows PREQUISITES : 1. Download the HexEdit.ocx see attached. And put it is your script folder (No registration needed ! ) 2. Download IRunningObjectTable.au3 3. Run this script ; https://www.codeproject.com/Articles/1384/Hex-Editor-OCX-Control #AutoIt3Wrapper_UseX64=N ;~ Opt("WinTitleMatchMode", 2) #include <ColorConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <FileConstants.au3> #include "IRunningObjectTable.au3" #include <Array.au3> ; Initialize COM error handler $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") Global $hFileOD Global $hFile Global $hActiveX ; Load ActiveX module $hActiveX = DllOpen(@ScriptDir & "\HexEdit.ocx") ; Object identifiers Global Const $sCLSID = "{2E93307E-777D-49E4-886A-D5B04470796A}" Global Const $sIID = Default ; Create a simple GUI for our output Local $hHexEdit = GUICreate ( "Hex Editor", 1000, 580,(@DesktopWidth-1000)/2, (@DesktopHeight-580)/2 ) Local $idButton_About = GUICtrlCreateButton("About", 100, 10, 85, 25) Local $idButton_FileOpen = GUICtrlCreateButton("FileOpen", 10, 10, 85, 25) GUICtrlCreateGroup("Columns", 790, 40, 190, 90) Local $idInput = GUICtrlCreateInput("20", 800, 80, 60, 25) GUICtrlCreateUpdown($idInput) $sInput = GUICtrlRead($idInput) Local $idButton_Auto = GUICtrlCreateButton("Auto", 880, 80, 75, 25) GUICtrlCreateGroup("Address", 790, 180, 190, 90) Local $idAscii = GUICtrlCreateCheckbox("Address", 800, 180, 185, 25) Local $idAddress1 = GUICtrlCreateRadio("WORD", 800, 210, 120, 20) Local $idAddress2 = GUICtrlCreateRadio("DWORD", 800, 235, 120, 20) GUICtrlSetState($idAddress1, $GUI_CHECKED) GUICtrlCreateGroup("Data", 790, 280, 190, 90) Local $idData1 = GUICtrlCreateRadio("BYTE", 800, 300, 120, 20) Local $idData2 = GUICtrlCreateRadio("WORD", 800, 320, 120, 20) Local $idData3 = GUICtrlCreateRadio("DWORD", 800, 340, 120, 20) GUICtrlSetState($idData1, $GUI_CHECKED) Local $idAscii = GUICtrlCreateCheckbox("Show ASCII", 800, 400, 185, 25) GUICtrlSetState(-1, 1) Local $idInvert = GUICtrlCreateCheckbox("Invert Color", 800, 430, 185, 25) Local $idLabel = GUICtrlCreateLabel("Modified : ", 800, 540, 185, 25) ; Create Com Object ;~ Local $oHexEdit = ObjCreate("HEXEDIT.HexEditCtrl.1") Local $oHexEdit = ObjCreate($sCLSID, $sIID, $hActiveX) If IsObj($oHexEdit) = 0 Then MsgBox(48, "Error", "Could not create the object, Common problem ActiveX not registered.") ConsoleWrite(IsObj($oHexEdit) & @CRLF) Exit EndIf $oHexEdit.Appearance = 1 $oHexEdit.AllowChangeSize = 0 $oHexEdit.BackColor = 0x000000 $oHexEdit.ForeColor = 0xffffff $oHexEdit.Fontheight = 16 $oHexEdit.Columns = Int($sInput) $GUIActiveX = GUICtrlCreateObj ($oHexEdit, 10, 40, 750, 520) GUICtrlSetResizing ( $GUIActiveX, $GUI_DOCKAUTO) GUICtrlSetData($idLabel, "Modified ; " & $oHexEdit.DataModified) ; Show GUI GUISetState () ; Loop GUI While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $GUI_EVENT_PRIMARYDOWN GUICtrlSetData($idLabel, "Modified ; " & $oHexEdit.DataModified) If $oHexEdit.DataModified = True Then GUICtrlSetColor($idLabel, $COLOR_RED) EndIf Case $idButton_About $oHexEdit.AboutBox() Case $idButton_Auto $oHexEdit.Columns = 0 Case $idInput $oHexEdit.Columns = GUICtrlRead($idInput) Case $idAscii If BitAND(GUICtrlRead($idAscii), $GUI_CHECKED) = $GUI_CHECKED Then $oHexEdit.ShowAscii = 1 Else $oHexEdit.ShowAscii = 0 EndIf Case $idInvert If BitAND(GUICtrlRead($idInvert), $GUI_CHECKED) = $GUI_CHECKED Then $oHexEdit.BackColor = 0xffffff $oHexEdit.ForeColor = 0x000000 Else $oHexEdit.BackColor = 0x000000 $oHexEdit.ForeColor = 0xffffff EndIf Case $idButton_FileOpen Set_Data(GetFile()) If BitAND(GUICtrlRead($idAddress1), $GUI_CHECKED) = $GUI_CHECKED Then $oHexEdit.DigitsInAddress = 4 EndIf If BitAND(GUICtrlRead($idAddress2), $GUI_CHECKED) = $GUI_CHECKED Then $oHexEdit.DigitsInAddress = 8 EndIf If BitAND(GUICtrlRead($idData1), $GUI_CHECKED) = $GUI_CHECKED Then $oHexEdit.DigitsInData = 2 EndIf If BitAND(GUICtrlRead($idData2), $GUI_CHECKED) = $GUI_CHECKED Then $oHexEdit.DigitsInData = 4 EndIf If BitAND(GUICtrlRead($idData2), $GUI_CHECKED) = $GUI_CHECKED Then $oHexEdit.DigitsInData = 8 EndIf EndSwitch WEnd ; Function File Open Func GetFile() $hFileOD = FileOpenDialog("Select EXE File", @ScriptDir & "\", "EXE (*.exe)") $hFileOpen = FileOpen($hFileOD, 16) If $hFileOpen = -1 Then MsgBox(48, "Error", "Unable to open file, or no file selected !!") Else ; Read the contents of the file using the handle returned by FileOpen. Local $sFileRead = FileRead($hFileOpen) Return $sFileRead EndIf ; Close the handle returned by FileOpen. FileClose($hFileOpen) EndFunc Func Set_Data($dBinary) ; https://www.autoitscript.com/forum/topic/202618-implementing-irunningobjecttable-interface/?do=findComment&comment=1471171 Local $sDictionaryData = "DictionaryData" ROT_RegisterObject( Default, $sDictionaryData ) ; Default => Object = Dictionary object Local $oROTobj = ObjGet( $sDictionaryData ) ; Dictionary object $oROTobj( "oHexEdit" ) = $oHexEdit $oROTobj( "dBinary" ) = $dBinary Local $code= 'Dim oROTobj, oHexEdit, dBinary' $code=$code & @CRLF & 'Set oROTobj = GetObject( "DictionaryData" )' $code=$code & @CRLF & 'Set oHexEdit = oROTobj( "oHexEdit" )' $code=$code & @CRLF & 'dBinary = oROTobj( "dBinary" )' $code=$code & @CRLF & 'oHexEdit.SetData dBinary, 0' Local $vbs = ObjCreate("ScriptControl") $vbs.language="vbscript" $vbs.addcode($code) ;~ ROT_Revoke($oROTobj) EndFunc ; COM Error Handler Func MyErrFunc() $HexNumber=hex($oMyError.number,8) Msgbox(0,"AutoItCOM","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $HexNumber & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) SetError(1) Endfunc Enjoy !! PS : I did not implement the write back to file yet. Feel free to add this if needed. HexEdit.zip
    3 points
  2. LarsJ

    UI Automation UDFs

    To make it easier to maintain the UIA code, I've decided to split the code this way: This new thread is used for the actual UIA UDFs. Ie. the files stored in Includes folders and named UIA_*.au3 or UIAEH_*.au3. The UIASpy thread contains only code that is used directly in the UIASpy GUI, but not the UIA UDFs in this new thread. Using UIA Code contains only example code, but neither UIA UDFs nor UIASpy. UIA Events contains GUI code to detect events and it contains example code, but neither UIA UDFs nor UIASpy. This means that every time the code in the UDF files in this new thread is updated (eg. because of Windows 10 feature updates twice a year), you must install the files in the Includes folders in the other threads yourself. The easiest way is simply to copy all UDF files to the Includes folders. UDF Files CUIAutomation2.au3 - UIA constants for Windows 7 used in the first examples CUIAutomation2-a.au3 - The original UIA constants for Windows 7 from junkew's thread UIA_AccVars.au3 - Used to calculate properties of type VT_UNKNOWN, copied and modified from this thread UIA_Constants.au3 - UIA constants (copied from UIA header files) up to and including Windows 10 1809 UIA_ConstNames.au3 - Contains functions for converting UIA constants from values to names UIA_Functions.au3 - A collection of small utility functions UIA_Functions-a.au3 - First version of utility functions UIA_ObjectFromTag.au3 - Creates callback objects used in event handlers, copied and modified from this post by trancexx UIA_SafeArray.au3 - Constants and functions to handle safearrays, copied from this thread UIA_Variant.au3 - Constants and functions to handle variants, copied from this thread UIAEH_AutomationEventHandler.au3 - Implements the AutomationEventHandler UIAEH_FocusChangedEventHandler.au3 - Implements the FocusChangedEventHandler UIAEH_NotificationEventHandler.au3 - Implements the NotificationEventHandler, published in Windows 10 1709 UIAEH_PropertyChangedEventHandler.au3 - Implements the PropertyChangedEventHandler UIAEH_StructureChangedEventHandler.au3 - Implements the StructureChangedEventHandler Folders The UI Automation projects can be stored in a folder structure this way: UI Automation\ Code\ - Using UIA code Events\ - UIA events Spy tool\ - UIASpy.au3 UDFs\ - UDF files The UDF files must be installed in Includes\ in the first three folders. Threads UIASpy - UI Automation Spy Tool is a GUI tool that provides information about windows and controls and their interconnection and provides functionality to generate sample code. UIASpy is essential for creating UI Automation code. In Using UI Automation Code in AutoIt you can find and download examples and read information about using UIA code. UI Automation Events is about implementing event handlers and includes GUIs to detect events. IUIAutomation MS framework automate chrome, FF, IE, .... created by junkew August 2013 is the first AutoIt thread on UIA code. Zip-file The zip contains source code for the UDF files. You need AutoIt 3.3.12 or later. Tested on Windows XP, Windows 7 and Windows 10. Comments are welcome. Let me know if there are any issues. UIAIncludes.7z
    1 point
  3. That's doesn't appear to me to be a webdriver crash. Rather, it's the webdriver returning an error that indicates that the web browser crashed. Can't tell from the limited information you supplied, but I'm assuming that this is from the _WD_ExecuteScript call within _WD_NewTab. This is still the wrong syntax, so no wonder it isn't working for you. 🙄
    1 point
  4. KaFu

    Color contrast issue

    Split both colors into R G B, compare the components separately against a total threshold (e.g. threshold 10, test and tweak to find a good value) and alter brightness if sum of distances is too low? Here in pseudo-code: Color 1: 0x121212 Color 2: 0x141414 if abs(12-14) + abs(12-14) + abs(12-14) < 10 then adjust brightness
    1 point
  5. @Professor_Bernd This is the registration free AutoIT example that shows a TOOLTIP on your screen. #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Version=beta #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=Y Global $hActiveX ; Load the ActiveX Module If @AutoItX64 Then $hActiveX = DllOpen(@ScriptDir & "\AutoItX3_x64.dll") Else $hActiveX = DllOpen(@ScriptDir & "\AutoItX3.dll") EndIf ;MsgBox(0,"x64",@AutoItX64) ; Object identifiers Global Const $sCLSID = "{1A671297-FA74-4422-80FA-6C5D8CE4DE04}" Global Const $sIID = Default ; Or use keyword Default if you want to use the Default interface ID ; Error Monitoring Global $oError = ObjEvent("AutoIt.Error", "_ErrFunc") Func _ErrFunc() ConsoleWrite("! COM Error ! Number: 0x" & Hex($oError.number, 8) & " ScriptLine: " & $oError.scriptline & " - " & $oError.windescription & @CRLF) Return EndFunc ;==>_ErrFunc ; Create the hActiveX Local $oAutoIt = ObjCreate($sCLSID, $sIID, $hActiveX) If $oAutoIt = 0 Then MsgBox(16,"Error", "Could not create the object, Common problem ActiveX not registered.") ; This will create a tooltip in the upper left of the screen $oAutoIt.ToolTip ("This is a tooltip", 450, 200) $oAutoIt.Sleep (3000) ; Sleep to give tooltip time to display $oAutoIt = "" DllClose($hActiveX) Enjoy !
    1 point
  6. Hi, the difference comes from the fact that the FileReadToArray is reading line by line as opposed to FileRead which read the whole file. Later on the splitting will work on the whole read buffer and act on it allocating entries of the array more quicker as the delimiter is just the @CRLF. In the case of FileReadToArray the delimiter can be @CR Or @LF or @CRLF which done char by char. That certainly the main overhead. If we want the same speed FileReadToArray will need a new parameter defining the delimiter. Cheers
    1 point
  7. @mLipok Sorry I don't have a post to refer to, this info is from old discussions with trancexx many years ago. I don't have access to the source code either. But If you use some debugging tools like the very old but still usefull MS OLEView. You can see the COM object details to see the IID GUID's.
    1 point
  8. As described in the Wiki : Warning: blocking of running user functions which executes window messages with commands such as "MsgBox" can lead to unexpected behavior, the return to the system should be as fast as possible! I do not know if that can be the issue...
    1 point
  9. @mLipok This is the way trancexx created the feature in AutoIT. You can use either way to use the IID GUID In case there is only 1 interface in the COM Module you can refer to the IID Flag = DEFAULT Some ActiveX modules have multiple IID's so you need to refer to the by the relevant IID GUID.
    1 point
  10. Jos

    Ignore....

    BS ... and keep religion out please. This question doesn't belong here and you know it. I have told you not to post all over the place and the previous topic of yours was closed due to a violation of the forum rules. My patience with you is gone already for a while and this is the last drop. You will have a week without posting abilities to think about your future in our forums and I strongly advice you not to come back unless you change your attitude and approach. Jos PS: Your posts and answers will be split of as they do not belong here!
    1 point
  11. TheXman

    Ignore....

    Obviously you didn't understand any part of what I wrote. This topic is NOT the place for that question. So here, let me help you...shhhhhh...shhhhh...don't fight it...just go to sleep...that's it...go to sleep.
    1 point
  12. LarsJ

    MailSlot

    Data transfer between AutoIt and VBScript can be performed using ROT objects as demonstrated in this example. ROT objects also have the advantage that arrays can be transferred directly and that the internal data type of array elements and other variables is preserved during the data transfer.
    1 point
  13. ContextMenus This black window with the mouse hovering over Indicators... is not really a popup window. It's a context menu. Indicators... is a menu item. Windows commands are usually not used to manipulate context menus. You do not activate a context menu with eg. WinActivate or similar functions. The only action you take in connection with a context menu is to open the menu with a mouse right click. When the menu is open you can click a menu item to execute the corresponding function and the menu closes. The menu also closes as soon as it loses focus. Next time you need to use the context menu, you must open it again with a new mouse right click. ContextMenus and UIASpy Open UIASpy. Delete all top windows. Open Notepad. Right click in the Edit control to open the context menu. It should look like this: Hover the mouse over the Undo menu point and press F4. It should look like this: Switch to UIASpy. It closes the context menu. Because the menu is closed, all UI elements are red: The menu item "Right to left Reading order" will be used to demonstrate point 3) below. This is UIASpy information: Treeview Element MenuItem: Right to left Reading order Element Properties (identification) $UIA_AccessKeyPropertyId r $UIA_AutomationIdPropertyId 32768 $UIA_ControlTypePropertyId $UIA_MenuItemControlTypeId $UIA_NamePropertyId Right to left Reading order Element Properties (session unique) $UIA_ProcessIdPropertyId 4688 $UIA_RuntimeIdPropertyId 42,722022,2,-2147483646,4688,360907857,10 Element Properties (information) $UIA_BoundingRectanglePropertyId l=551,t=593,w=258,h=22 $UIA_LocalizedControlTypePropertyId menu item $UIA_ProviderDescriptionPropertyId [pid:4688,hwnd:0x0 Annotation:Microsoft: Annotation Proxy (unmanaged:uiautomationcore.dll); Main(parent link):Microsoft: MSAA Proxy (unmanaged:uiautomationcore.dll)] Element Properties (has/is info) $UIA_HasKeyboardFocusPropertyId True $UIA_IsContentElementPropertyId True $UIA_IsControlElementPropertyId True $UIA_IsDataValidForFormPropertyId False $UIA_IsEnabledPropertyId True $UIA_IsKeyboardFocusablePropertyId False $UIA_IsOffscreenPropertyId False $UIA_IsPasswordPropertyId False $UIA_IsRequiredForFormPropertyId False Control Patterns (element actions) $UIA_IsInvokePatternAvailablePropertyId True (InvokePattern) $UIA_IsLegacyIAccessiblePatternAvailablePropertyId True (LegacyIAccessiblePattern) Control Pattern Properties $UIA_LegacyIAccessibleChildIdPropertyId 10 $UIA_LegacyIAccessibleDefaultActionPropertyId Execute $UIA_LegacyIAccessibleDescriptionPropertyId $UIA_LegacyIAccessibleHelpPropertyId $UIA_LegacyIAccessibleKeyboardShortcutPropertyId r $UIA_LegacyIAccessibleNamePropertyId Right to left Reading order $UIA_LegacyIAccessibleRolePropertyId 12 = $ROLE_SYSTEM_MENUITEM $UIA_LegacyIAccessibleStatePropertyId 132 = $STATE_SYSTEM_FOCUSED+$STATE_SYSTEM_HOTTRACKED $UIA_LegacyIAccessibleValuePropertyId Control Pattern Methods Invoke Pattern Methods Invoke() LegacyIAccessible Pattern Methods DoDefaultAction() Select(long) SetValue(wstr) GetIAccessible(idispatch*) CurrentChildId(int*) CurrentDefaultAction(bstr*) CurrentDescription(bstr*) CurrentHelp(bstr*) CurrentKeyboardShortcut(bstr*) CurrentName(bstr*) CurrentRole(uint*) CurrentState(uint*) CurrentValue(bstr*) GetCurrentSelection(ptr*) Parents from Desktop Pane: Desktop Menu: Context Parent to child index Note that the Invoke Pattern is supported so that the menu item can be invoked (Invoke()). Your issues As far as I understand from your first post, you want to automate the following three tasks: 1) Open the context menu 2) Detect the open context menu 3) Click Indicators... menu item Point 3) also closes the menu. Solutions I'll demonstrate how the three tasks are solved with the context menu in Notepad. First try the Notepad examples and remember to correct language specific texts for your own language. Then you can customize the examples and try them out with your own program. All code is in the zip-file at the bottom. 2) Detect the open context menu We'll start with task 2). The code in tst02.au3 is copied directly from the zip-file in this post. Run tst02.au3 in SciTE. It prints information in console. Right click in the Edit control in Notepad to open the context menu. Watch output in SciTE console. tst02.au3 keeps running until you stop it with Esc. You can test tst02.au3 with your own program without changing any code at all. tst02.au3 should be able to identify your context menu. tst02.au3: #include "CUIAutomation2.au3" #include "ObjectFromTag.au3" Opt( "MustDeclareVars", 1 ) Global Const $S_OK = 0x00000000 Global Const $E_NOINTERFACE = 0x80004002 Global Const $sIID_IUnknown = "{00000000-0000-0000-C000-000000000046}" Global $tIUIAutomationEventHandler, $oIUIAutomationEventHandler Global $oUIAutomation Example() Func Example() $oIUIAutomationEventHandler = ObjectFromTag( "oIUIAutomationEventHandler_", $dtagIUIAutomationEventHandler, $tIUIAutomationEventHandler, True ) If Not IsObj( $oIUIAutomationEventHandler ) Then Return $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return Local $pUIElement $oUIAutomation.GetRootElement( $pUIElement ) ; Desktop If Not $pUIElement Then Return ; Window open/close events ;If $oUIAutomation.AddAutomationEventHandler( $UIA_Window_WindowOpenedEventId, $pUIElement, $TreeScope_Subtree, 0, $oIUIAutomationEventHandler ) Then Exit ;If $oUIAutomation.AddAutomationEventHandler( $UIA_Window_WindowClosedEventId, $pUIElement, $TreeScope_Subtree, 0, $oIUIAutomationEventHandler ) Then Exit ; Menu open/close events If $oUIAutomation.AddAutomationEventHandler( $UIA_MenuOpenedEventId, $pUIElement, $TreeScope_Subtree, 0, $oIUIAutomationEventHandler ) Then Exit ;If $oUIAutomation.AddAutomationEventHandler( $UIA_MenuClosedEventId, $pUIElement, $TreeScope_Subtree, 0, $oIUIAutomationEventHandler ) Then Exit HotKeySet( "{ESC}", "Quit" ) While Sleep(10) WEnd EndFunc Func Quit() $oIUIAutomationEventHandler = 0 DeleteObjectFromTag( $tIUIAutomationEventHandler ) Exit EndFunc Func _UIA_getPropertyValue( $obj, $id ) Local $tVal $obj.GetCurrentPropertyValue( $id, $tVal ) Return $tVal EndFunc Func oIUIAutomationEventHandler_HandleAutomationEvent( $pSelf, $pSender, $iEventId ) ; Ret: long Par: ptr;int ConsoleWrite( "oIUIAutomationEventHandler_HandleAutomationEvent: " & $iEventId & @CRLF ) If $iEventId <> $UIA_Window_WindowClosedEventId Then Local $oSender = ObjCreateInterface( $pSender, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) $oSender.AddRef() Local $hWindow = _UIA_getPropertyValue( $oSender, $UIA_NativeWindowHandlePropertyId ) ConsoleWrite( "Title = " & _UIA_getPropertyValue( $oSender, $UIA_NamePropertyId ) & @CRLF & _ "Class = " & _UIA_getPropertyValue( $oSender, $UIA_ClassNamePropertyId ) & @CRLF & _ "Ctrl type = " & _UIA_getPropertyValue( $oSender, $UIA_ControlTypePropertyId ) & @CRLF & _ "Ctrl name = " & _UIA_getPropertyValue( $oSender, $UIA_LocalizedControlTypePropertyId ) & @CRLF & _ "Value = " & _UIA_getPropertyValue( $oSender, $UIA_LegacyIAccessibleValuePropertyId ) & @CRLF & _ "Handle = " & Hex( $hWindow ) & @CRLF & @CRLF ) ; Get UI Automation element from window handle Local $pWindow, $oWindow $oUIAutomation.ElementFromHandle( $hWindow, $pWindow ) $oWindow = ObjCreateInterface( $pWindow, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oWindow ) Then Return ConsoleWrite( "Automation element from window error" & @CRLF ) ; List all elements of window ListDescendants( $oWindow, 0, 0 ) EndIf Return $S_OK EndFunc ; List all child elements of parent Func ListDescendants( $oParent, $iLevel, $iLevels = 0 ) If Not IsObj( $oParent ) Then Return If $iLevels And $iLevel = $iLevels Then Return ; Create RawViewWalker object Local $pRawViewWalker, $oRawViewWalker $oUIAutomation.RawViewWalker( $pRawViewWalker ) $oRawViewWalker = ObjCreateInterface( $pRawViewWalker, $sIID_IUIAutomationTreeWalker, $dtagIUIAutomationTreeWalker ) If Not IsObj( $oRawViewWalker ) Then Return ConsoleWrite( "RawViewWalker object error" & @CRLF ) ; Get first child element Local $pUIElement, $oUIElement $oRawViewWalker.GetFirstChildElement( $oParent, $pUIElement ) $oUIElement = ObjCreateInterface( $pUIElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) Local $sIndent = "" For $i = 0 To $iLevel - 1 $sIndent &= " " Next While IsObj( $oUIElement ) ConsoleWrite( $sIndent & "Title = " & _UIA_getPropertyValue( $oUIElement, $UIA_NamePropertyId ) & @CRLF & _ $sIndent & "Class = " & _UIA_getPropertyValue( $oUIElement, $UIA_ClassNamePropertyId ) & @CRLF & _ $sIndent & "Ctrl type = " & _UIA_getPropertyValue( $oUIElement, $UIA_ControlTypePropertyId ) & @CRLF & _ $sIndent & "Ctrl name = " & _UIA_getPropertyValue( $oUIElement, $UIA_LocalizedControlTypePropertyId ) & @CRLF & _ $sIndent & "Value = " & _UIA_getPropertyValue( $oUIElement, $UIA_LegacyIAccessibleValuePropertyId ) & @CRLF & _ $sIndent & "Handle = " & Hex( _UIA_getPropertyValue( $oUIElement, $UIA_NativeWindowHandlePropertyId ) ) & @CRLF & @CRLF ) ListDescendants( $oUIElement, $iLevel + 1, $iLevels ) $oRawViewWalker.GetNextSiblingElement( $oUIElement, $pUIElement ) $oUIElement = ObjCreateInterface( $pUIElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) WEnd EndFunc Func oIUIAutomationEventHandler_QueryInterface( $pSelf, $pRIID, $pObj ) ; Ret: long Par: ptr;ptr* Local $sIID = StringFromGUID( $pRIID ) If $sIID = $sIID_IUnknown Then ConsoleWrite( "oIUIAutomationEventHandler_QueryInterface: IUnknown" & @CRLF ) DllStructSetData( DllStructCreate( "ptr", $pObj ), 1, $pSelf ) oIUIAutomationEventHandler_AddRef( $pSelf ) Return $S_OK ElseIf $sIID = $sIID_IUIAutomationEventHandler Then ConsoleWrite( "oIUIAutomationEventHandler_QueryInterface: IUIAutomationEventHandler" & @CRLF ) DllStructSetData( DllStructCreate( "ptr", $pObj ), 1, $pSelf ) oIUIAutomationEventHandler_AddRef( $pSelf ) Return $S_OK Else ConsoleWrite( "oIUIAutomationEventHandler_QueryInterface: " & $sIID & @CRLF ) Return $E_NOINTERFACE EndIf EndFunc Func oIUIAutomationEventHandler_AddRef( $pSelf ) ; Ret: ulong ConsoleWrite( "oIUIAutomationEventHandler_AddRef" & @CRLF ) Return 1 EndFunc Func oIUIAutomationEventHandler_Release( $pSelf ) ; Ret: ulong ConsoleWrite( "oIUIAutomationEventHandler_Release" & @CRLF ) Return 1 EndFunc Func StringFromGUID( $pGUID ) Local $aResult = DllCall( "ole32.dll", "int", "StringFromGUID2", "struct*", $pGUID, "wstr", "", "int", 40 ) If @error Then Return SetError( @error, @extended, "" ) Return SetExtended( $aResult[0], $aResult[2] ) EndFunc Console output: Func oIUIAutomationEventHandler_QueryInterface( $pSelf ) ; Ret: long Par: ptr;ptr EndFunc 0 Func oIUIAutomationEventHandler_AddRef( $pSelf ) ; Ret: dword EndFunc 0 Func oIUIAutomationEventHandler_Release( $pSelf ) ; Ret: dword EndFunc 0 Func oIUIAutomationEventHandler_HandleAutomationEvent( $pSelf ) ; Ret: long Par: ptr;int EndFunc 0 oIUIAutomationEventHandler_QueryInterface: IUnknown oIUIAutomationEventHandler_AddRef oIUIAutomationEventHandler_Release oIUIAutomationEventHandler_AddRef oIUIAutomationEventHandler_QueryInterface: {0000001B-0000-0000-C000-000000000046} oIUIAutomationEventHandler_QueryInterface: {00000003-0000-0000-C000-000000000046} oIUIAutomationEventHandler_AddRef oIUIAutomationEventHandler_QueryInterface: {0000001B-0000-0000-C000-000000000046} oIUIAutomationEventHandler_QueryInterface: IUnknown oIUIAutomationEventHandler_AddRef oIUIAutomationEventHandler_AddRef oIUIAutomationEventHandler_QueryInterface: {00000018-0000-0000-C000-000000000046} oIUIAutomationEventHandler_QueryInterface: {00000019-0000-0000-C000-000000000046} oIUIAutomationEventHandler_QueryInterface: {4C1E39E1-E3E3-4296-AA86-EC938D896E92} oIUIAutomationEventHandler_Release oIUIAutomationEventHandler_QueryInterface: IUIAutomationEventHandler oIUIAutomationEventHandler_AddRef oIUIAutomationEventHandler_AddRef oIUIAutomationEventHandler_QueryInterface: {1C733A30-2A1C-11CE-ADE5-00AA0044773D} oIUIAutomationEventHandler_QueryInterface: IUIAutomationEventHandler oIUIAutomationEventHandler_AddRef oIUIAutomationEventHandler_HandleAutomationEvent: 20003 Title = Context Class = #32768 Ctrl type = 50009 Ctrl name = menu Value = Handle = 000E039C Title = Undo Class = Ctrl type = 50011 Ctrl name = menu item Value = Handle = 00000000 Title = Class = Ctrl type = 50038 Ctrl name = separator Value = Handle = 00000000 Title = Cut Class = Ctrl type = 50011 Ctrl name = menu item Value = Handle = 00000000 Title = Copy Class = Ctrl type = 50011 Ctrl name = menu item Value = Handle = 00000000 Title = Paste Class = Ctrl type = 50011 Ctrl name = menu item Value = Handle = 00000000 Title = Delete Class = Ctrl type = 50011 Ctrl name = menu item Value = Handle = 00000000 Title = Class = Ctrl type = 50038 Ctrl name = separator Value = Handle = 00000000 Title = Select All Class = Ctrl type = 50011 Ctrl name = menu item Value = Handle = 00000000 Title = Class = Ctrl type = 50038 Ctrl name = separator Value = Handle = 00000000 Title = Right to left Reading order Class = Ctrl type = 50011 Ctrl name = menu item Value = Handle = 00000000 Title = Show Unicode control characters Class = Ctrl type = 50011 Ctrl name = menu item Value = Handle = 00000000 Title = Insert Unicode control character Class = Ctrl type = 50011 Ctrl name = menu item Value = Handle = 00000000 Title = Class = Ctrl type = 50038 Ctrl name = separator Value = Handle = 00000000 Title = Open IME Class = Ctrl type = 50011 Ctrl name = menu item Value = Handle = 00000000 Title = Reconversion Class = Ctrl type = 50011 Ctrl name = menu item Value = Handle = 00000000 oIUIAutomationEventHandler_Release 1) Open the context menu So far, there is no UI Automation method to open a context menu. You open a context menu by mimicking the manual method in programming: Set focus to window and control and perform a mouse right click. Notepad must be open beforehand. Run tst01.au3 in SciTE. tst01.au3 opens the context menu in Notepad edit control when you click the buttons in the GUI. But no menu items are executed. To customize tst01.au3 to your own program, the UI Automation code in particular needs to be corrected. You can also delete one of the buttons and correct the text on the other. tst01.au3: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 Opt( "MustDeclareVars", 1 ) #include "UIA_Constants.au3" ; Can be copied from UIASpy Includes folder #include "UIA_Functions.au3" ; Can be copied from UIASpy Includes folder #include <GUIConstantsEx.au3> Example() Func Example() ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtag_IUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return ConsoleWrite( "$oUIAutomation ERR" & @CRLF ) ConsoleWrite( "$oUIAutomation OK" & @CRLF ) ; Get Desktop element Local $pDesktop, $oDesktop $oUIAutomation.GetRootElement( $pDesktop ) $oDesktop = ObjCreateInterface( $pDesktop, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement ) If Not IsObj( $oDesktop ) Then Return ConsoleWrite( "$oDesktop ERR" & @CRLF ) ConsoleWrite( "$oDesktop OK" & @CRLF ) ; --- Find window/control --- ConsoleWrite( "--- Find window/control ---" & @CRLF ) Local $pCondition0 $oUIAutomation.CreatePropertyCondition( $UIA_ClassNamePropertyId, "Notepad", $pCondition0 ) If Not $pCondition0 Then Return ConsoleWrite( "$pCondition0 ERR" & @CRLF ) ConsoleWrite( "$pCondition0 OK" & @CRLF ) Local $pNotepad, $oNotepad $oDesktop.FindFirst( $TreeScope_Descendants, $pCondition0, $pNotepad ) $oNotepad = ObjCreateInterface( $pNotepad, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement ) If Not IsObj( $oNotepad ) Then Return ConsoleWrite( "$oNotepad ERR" & @CRLF ) ConsoleWrite( "$oNotepad OK" & @CRLF ) ; --- Find window/control --- ConsoleWrite( "--- Find window/control ---" & @CRLF ) Local $pCondition1 $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_EditControlTypeId, $pCondition1 ) If Not $pCondition1 Then Return ConsoleWrite( "$pCondition1 ERR" & @CRLF ) ConsoleWrite( "$pCondition1 OK" & @CRLF ) Local $pEdit1, $oEdit1 $oNotepad.FindFirst( $TreeScope_Descendants, $pCondition1, $pEdit1 ) $oEdit1 = ObjCreateInterface( $pEdit1, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement ) If Not IsObj( $oEdit1 ) Then Return ConsoleWrite( "$oEdit1 ERR" & @CRLF ) ConsoleWrite( "$oEdit1 OK" & @CRLF ) ; --- Create GUI --- Local $hGui = GUICreate( "Automate Notepad Context Menu", 330, 40, 100, 100 ) Local $idRight = GUICtrlCreateButton( "Right to left Reading order", 10, 10, 150, 20 ) Local $idLeft = GUICtrlCreateButton( "Left to right Reading order", 170, 10, 150, 20 ) GUICtrlSetState( $idLeft, $GUI_DISABLE ) GUISetState( @SW_SHOW ) Local $iMsg While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $idRight, $idLeft ; --- Element Properties (information) --- ConsoleWrite( "--- Element Properties (information) ---" & @CRLF ) Local $asBoundingRectangle1 $oEdit1.GetCurrentPropertyValue( $UIA_BoundingRectanglePropertyId, $asBoundingRectangle1 ) UIA_GetArrayPropertyValueAsString( $asBoundingRectangle1 ) ConsoleWrite( "$asBoundingRectangle1 = " & $asBoundingRectangle1 & @CRLF ) Local $aBoundingRectangle1 = StringSplit( $asBoundingRectangle1, ",", 2 ) ; 2 = $STR_NOCOUNT ; --- Secondary mouse click --- UIA_WinActivate( $oNotepad ) Sleep( 100 ) Local $aPos = MouseGetPos() DllCall( "user32.dll", "int", "ShowCursor", "bool", False ) MouseClick( "secondary", $aBoundingRectangle1[0]+100, $aBoundingRectangle1[1]+100, 1, 0 ) GUICtrlSetState( $iMsg = $idRight ? $idRight : $idLeft, $GUI_DISABLE ) GUICtrlSetState( $iMsg = $idRight ? $idLeft : $idRight, $GUI_ENABLE ) MouseMove( $aPos[0], $aPos[1], 0 ) DllCall( "user32.dll", "int", "ShowCursor", "bool", True ) Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete( $hGui ) EndFunc Console output: $oUIAutomation OK $oDesktop OK --- Find window/control --- $pCondition0 OK $oNotepad OK --- Find window/control --- $pCondition1 OK $oEdit1 OK --- Element Properties (information) --- $asBoundingRectangle1 = 258,100,984,842 --- Element Properties (information) --- $asBoundingRectangle1 = 258,100,984,842 --- Element Properties (information) --- $asBoundingRectangle1 = 258,100,984,842 --- Element Properties (information) --- $asBoundingRectangle1 = 258,100,984,842 --- Element Properties (information) --- $asBoundingRectangle1 = 258,100,984,842 --- Element Properties (information) --- $asBoundingRectangle1 = 258,100,984,842 3) Click Indicators... menu item (your program) 3) Click "Right to left Reading order" menu item (Notepad) Type a text eg. "Test" in Notepad. tst03.au3 is a combination of tst01.au3 and tst02.au3. And then code is added to execute a menu item in the context menu. It's the "Case $idContextMenu" section of the main loop. Run tst03.au3 in SciTE in the same way as tst01.au3. To test your own program, make the same corrections in tst03.au3 as in tst01.au3. And then you have to correct the "Case $idContextMenu" section. tst03.au3: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 Opt( "MustDeclareVars", 1 ) #include "UIA_Constants.au3" ; Can be copied from UIASpy Includes folder #include "UIA_Functions.au3" ; Can be copied from UIASpy Includes folder #include "ObjectFromTag.au3" #include <GUIConstantsEx.au3> Global Const $S_OK = 0x00000000 Global Const $E_NOINTERFACE = 0x80004002 Global Const $sIID_IUnknown = "{00000000-0000-0000-C000-000000000046}" Global $oUIAutomation, $tIUIAutomationEventHandler, $oIUIAutomationEventHandler Global $idContextMenu, $oContextMenu Example() Func Example() ; Create UI Automation object $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtag_IUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return ConsoleWrite( "$oUIAutomation ERR" & @CRLF ) ConsoleWrite( "$oUIAutomation OK" & @CRLF ) ; Get Desktop element Local $pDesktop, $oDesktop $oUIAutomation.GetRootElement( $pDesktop ) $oDesktop = ObjCreateInterface( $pDesktop, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement ) If Not IsObj( $oDesktop ) Then Return ConsoleWrite( "$oDesktop ERR" & @CRLF ) ConsoleWrite( "$oDesktop OK" & @CRLF ) ; --- Create UI Automation event handler --- ConsoleWrite( "--- Create UI Automation event handler ---" & @CRLF ) ; Create UI Automation event handler $oIUIAutomationEventHandler = ObjectFromTag( "oIUIAutomationEventHandler_", $dtag_IUIAutomationEventHandler, $tIUIAutomationEventHandler, True ) If Not IsObj( $oIUIAutomationEventHandler ) Then Return ConsoleWrite( "$oIUIAutomationEventHandler ERR" & @CRLF ) ConsoleWrite( "$oIUIAutomationEventHandler OK" & @CRLF ) ; Menu open/close events If $oUIAutomation.AddAutomationEventHandler( $UIA_MenuOpenedEventId, $pDesktop, $TreeScope_Subtree, 0, $oIUIAutomationEventHandler ) Then Return ConsoleWrite( "AddAutomationEventHandler ERR" & @CRLF ) ConsoleWrite( "AddAutomationEventHandler OK" & @CRLF ) ; --- Find window/control --- ConsoleWrite( "--- Find window/control ---" & @CRLF ) Local $pCondition0 $oUIAutomation.CreatePropertyCondition( $UIA_ClassNamePropertyId, "Notepad", $pCondition0 ) If Not $pCondition0 Then Return ConsoleWrite( "$pCondition0 ERR" & @CRLF ) ConsoleWrite( "$pCondition0 OK" & @CRLF ) Local $pNotepad, $oNotepad $oDesktop.FindFirst( $TreeScope_Descendants, $pCondition0, $pNotepad ) $oNotepad = ObjCreateInterface( $pNotepad, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement ) If Not IsObj( $oNotepad ) Then Return ConsoleWrite( "$oNotepad ERR" & @CRLF ) ConsoleWrite( "$oNotepad OK" & @CRLF ) ; --- Find window/control --- ConsoleWrite( "--- Find window/control ---" & @CRLF ) Local $pCondition1 $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_EditControlTypeId, $pCondition1 ) If Not $pCondition1 Then Return ConsoleWrite( "$pCondition1 ERR" & @CRLF ) ConsoleWrite( "$pCondition1 OK" & @CRLF ) Local $pEdit1, $oEdit1 $oNotepad.FindFirst( $TreeScope_Descendants, $pCondition1, $pEdit1 ) $oEdit1 = ObjCreateInterface( $pEdit1, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement ) If Not IsObj( $oEdit1 ) Then Return ConsoleWrite( "$oEdit1 ERR" & @CRLF ) ConsoleWrite( "$oEdit1 OK" & @CRLF ) Local $hGui = GUICreate( "Automate Notepad Context Menu", 330, 40, 100, 100 ) Local $idRight = GUICtrlCreateButton( "Right to left Reading order", 10, 10, 150, 20 ) Local $idLeft = GUICtrlCreateButton( "Left to right Reading order", 170, 10, 150, 20 ) GUICtrlSetState( $idLeft, $GUI_DISABLE ) $idContextMenu = GUICtrlCreateDummy() GUISetState( @SW_SHOW ) Local $iMsg While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $idRight, $idLeft ; --- Element Properties (information) --- ConsoleWrite( "--- Element Properties (information) ---" & @CRLF ) Local $asBoundingRectangle1 $oEdit1.GetCurrentPropertyValue( $UIA_BoundingRectanglePropertyId, $asBoundingRectangle1 ) UIA_GetArrayPropertyValueAsString( $asBoundingRectangle1 ) ConsoleWrite( "$asBoundingRectangle1 = " & $asBoundingRectangle1 & @CRLF ) Local $aBoundingRectangle1 = StringSplit( $asBoundingRectangle1, ",", 2 ) ; 2 = $STR_NOCOUNT ; --- Secondary mouse click --- UIA_WinActivate( $oNotepad ) Sleep( 100 ) Local $aPos = MouseGetPos() DllCall( "user32.dll", "int", "ShowCursor", "bool", False ) MouseClick( "secondary", $aBoundingRectangle1[0]+100, $aBoundingRectangle1[1]+100, 1, 0 ) GUICtrlSetState( $iMsg = $idRight ? $idRight : $idLeft, $GUI_DISABLE ) GUICtrlSetState( $iMsg = $idRight ? $idLeft : $idRight, $GUI_ENABLE ) MouseMove( $aPos[0], $aPos[1], 0 ) DllCall( "user32.dll", "int", "ShowCursor", "bool", True ) Case $idContextMenu ConsoleWrite( "ContextMenu handler" & @CRLF ) Local $pAndCondition1 $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_MenuItemControlTypeId, $pCondition0 ) $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "Right to left Reading order", $pCondition1 ) $oUIAutomation.CreateAndCondition( $pCondition0, $pCondition1, $pAndCondition1 ) If Not $pAndCondition1 Then Return ConsoleWrite( "$pAndCondition1 ERR" & @CRLF ) ConsoleWrite( "$pAndCondition1 OK" & @CRLF ) Local $pMenuItem1, $oMenuItem1 $oContextMenu.FindFirst( $TreeScope_Descendants, $pAndCondition1, $pMenuItem1 ) $oMenuItem1 = ObjCreateInterface( $pMenuItem1, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement ) If Not IsObj( $oMenuItem1 ) Then Return ConsoleWrite( "$oMenuItem1 ERR" & @CRLF ) ConsoleWrite( "$oMenuItem1 OK" & @CRLF ) Local $pInvokePattern1, $oInvokePattern1 $oMenuItem1.GetCurrentPattern( $UIA_InvokePatternId, $pInvokePattern1 ) $oInvokePattern1 = ObjCreateInterface( $pInvokePattern1, $sIID_IUIAutomationInvokePattern, $dtag_IUIAutomationInvokePattern ) If Not IsObj( $oInvokePattern1 ) Then Return ConsoleWrite( "$oInvokePattern1 ERR" & @CRLF ) ConsoleWrite( "$oInvokePattern1 OK" & @CRLF ) $oInvokePattern1.Invoke() ConsoleWrite( "$oInvokePattern1.Invoke()" & @CRLF ) Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete( $hGui ) $oIUIAutomationEventHandler = 0 DeleteObjectFromTag( $tIUIAutomationEventHandler ) EndFunc Func oIUIAutomationEventHandler_HandleAutomationEvent( $pSelf, $pSender, $iEventId ) ; Ret: long Par: ptr;int ConsoleWrite( "oIUIAutomationEventHandler_HandleAutomationEvent: " & $iEventId & @CRLF ) $oContextMenu = ObjCreateInterface( $pSender, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement ) $oContextMenu.AddRef() If Not IsObj( $oContextMenu ) Then Return ConsoleWrite( "$oContextMenu ERR" & @CRLF ) ConsoleWrite( "$oContextMenu OK" & @CRLF ) GUICtrlSendToDummy( $idContextMenu ) Return $S_OK #forceref $pSelf EndFunc Func oIUIAutomationEventHandler_QueryInterface( $pSelf, $pRIID, $pObj ) ; Ret: long Par: ptr;ptr* Local $sIID = StringFromGUID( $pRIID ) If $sIID = $sIID_IUnknown Then ConsoleWrite( "oIUIAutomationEventHandler_QueryInterface: IUnknown" & @CRLF ) DllStructSetData( DllStructCreate( "ptr", $pObj ), 1, $pSelf ) oIUIAutomationEventHandler_AddRef( $pSelf ) Return $S_OK ElseIf $sIID = $sIID_IUIAutomationEventHandler Then ConsoleWrite( "oIUIAutomationEventHandler_QueryInterface: IUIAutomationEventHandler" & @CRLF ) DllStructSetData( DllStructCreate( "ptr", $pObj ), 1, $pSelf ) oIUIAutomationEventHandler_AddRef( $pSelf ) Return $S_OK Else ConsoleWrite( "oIUIAutomationEventHandler_QueryInterface: " & $sIID & @CRLF ) Return $E_NOINTERFACE EndIf #forceref $pSelf EndFunc Func oIUIAutomationEventHandler_AddRef( $pSelf ) ; Ret: ulong ConsoleWrite( "oIUIAutomationEventHandler_AddRef" & @CRLF ) Return 1 #forceref $pSelf EndFunc Func oIUIAutomationEventHandler_Release( $pSelf ) ; Ret: ulong ConsoleWrite( "oIUIAutomationEventHandler_Release" & @CRLF ) Return 1 #forceref $pSelf EndFunc Func StringFromGUID( $pGUID ) Local $aResult = DllCall( "ole32.dll", "int", "StringFromGUID2", "struct*", $pGUID, "wstr", "", "int", 40 ) If @error Then Return SetError( @error, @extended, "" ) Return SetExtended( $aResult[0], $aResult[2] ) EndFunc Console output: $oUIAutomation OK $oDesktop OK --- Create UI Automation event handler --- Func oIUIAutomationEventHandler_QueryInterface( $pSelf ) ; Ret: long Par: ptr;ptr EndFunc 0 Func oIUIAutomationEventHandler_AddRef( $pSelf ) ; Ret: dword EndFunc 0 Func oIUIAutomationEventHandler_Release( $pSelf ) ; Ret: dword EndFunc 0 Func oIUIAutomationEventHandler_HandleAutomationEvent( $pSelf ) ; Ret: long Par: ptr;int EndFunc 0 oIUIAutomationEventHandler_QueryInterface: IUnknown oIUIAutomationEventHandler_AddRef oIUIAutomationEventHandler_Release $oIUIAutomationEventHandler OK oIUIAutomationEventHandler_AddRef oIUIAutomationEventHandler_QueryInterface: {0000001B-0000-0000-C000-000000000046} oIUIAutomationEventHandler_QueryInterface: {00000003-0000-0000-C000-000000000046} oIUIAutomationEventHandler_AddRef AddAutomationEventHandler OK --- Find window/control --- $pCondition0 OK $oNotepad OK --- Find window/control --- $pCondition1 OK $oEdit1 OK --- Element Properties (information) --- $asBoundingRectangle1 = 258,100,984,842 oIUIAutomationEventHandler_QueryInterface: {0000001B-0000-0000-C000-000000000046} oIUIAutomationEventHandler_QueryInterface: IUnknown oIUIAutomationEventHandler_AddRef oIUIAutomationEventHandler_AddRef oIUIAutomationEventHandler_QueryInterface: {00000018-0000-0000-C000-000000000046} oIUIAutomationEventHandler_QueryInterface: {00000019-0000-0000-C000-000000000046} oIUIAutomationEventHandler_QueryInterface: {4C1E39E1-E3E3-4296-AA86-EC938D896E92} oIUIAutomationEventHandler_Release oIUIAutomationEventHandler_QueryInterface: IUIAutomationEventHandler oIUIAutomationEventHandler_AddRef oIUIAutomationEventHandler_AddRef oIUIAutomationEventHandler_QueryInterface: {1C733A30-2A1C-11CE-ADE5-00AA0044773D} oIUIAutomationEventHandler_QueryInterface: IUIAutomationEventHandler oIUIAutomationEventHandler_AddRef oIUIAutomationEventHandler_HandleAutomationEvent: 20003 $oContextMenu OK ContextMenu handler $pAndCondition1 OK $oMenuItem1 OK $oInvokePattern1 OK $oInvokePattern1.Invoke() --- Element Properties (information) --- $asBoundingRectangle1 = 258,100,984,842 oIUIAutomationEventHandler_HandleAutomationEvent: 20003 $oContextMenu OK ContextMenu handler $pAndCondition1 OK $oMenuItem1 OK $oInvokePattern1 OK $oInvokePattern1.Invoke() --- Element Properties (information) --- $asBoundingRectangle1 = 258,100,984,842 oIUIAutomationEventHandler_HandleAutomationEvent: 20003 $oContextMenu OK ContextMenu handler $pAndCondition1 OK $oMenuItem1 OK $oInvokePattern1 OK $oInvokePattern1.Invoke() --- Element Properties (information) --- $asBoundingRectangle1 = 258,100,984,842 oIUIAutomationEventHandler_HandleAutomationEvent: 20003 $oContextMenu OK ContextMenu handler $pAndCondition1 OK $oMenuItem1 OK $oInvokePattern1 OK $oInvokePattern1.Invoke() --- Element Properties (information) --- $asBoundingRectangle1 = 258,100,984,842 oIUIAutomationEventHandler_HandleAutomationEvent: 20003 $oContextMenu OK ContextMenu handler $pAndCondition1 OK $oMenuItem1 OK $oInvokePattern1 OK $oInvokePattern1.Invoke() --- Element Properties (information) --- $asBoundingRectangle1 = 258,100,984,842 oIUIAutomationEventHandler_HandleAutomationEvent: 20003 $oContextMenu OK ContextMenu handler $pAndCondition1 OK $oMenuItem1 OK $oInvokePattern1 OK $oInvokePattern1.Invoke() oIUIAutomationEventHandler_Release ContextMenu.7z
    1 point
  14. goodmanjl531, It seems that DirRemove does not honour wildcards - it does not say that it does in the Help file and my testing confirms that. So you will have to list the folders using _FileListToArray and then remove them individually - this code works for me: #include <File.au3> $sPath = "M:\" ; Change to match your required path $aList = _FileListToArray($sPath, "slu*.tmp", 2) For $i = 1 To $aList[0] DirRemove($sPath & $aList[$i], 1) Next M23
    1 point
  15. Hello, today i finished my bot for a game, i want share it free but not let the code so easy. No matter if later someone get it. its not a ultra bot, but at least it does the work . . . Is there a way to obfuscate free the code without extra files? Right now im running the script using a single file.au3 and i would like keep it like that. I cant use the free version of autoit because it has 960 lines code. I have been searching a while, and i cant find something
    0 points
×
×
  • Create New...