Leaderboard
Popular Content
Showing content with the highest reputation on 02/11/2023 in all areas
-
This example is about using Microsoft UI Automation APIs in AutoIt. Ie. it's about using interfaces, objects, methods, properties and constants as they are defined directly by Microsoft. In AutoIt, the definitions are contained in CUIAutomation2.au3 by junkew. The definitions are copied from corresponding C/C++ header files and customized the AutoIt language. This example is not about the functions in UIAWrappers.au3 by junkew. The purpose of the example is to show how to use Microsoft UI Automation APIs directly without any intermediate AutoIt functions. A major advantage of this approach is that the Microsoft documentation directly can be used as AutoIt documentation. Other major advantages are that there is no need for documenting and maintaining a set of intermediate AutoIt functions. Without intermediate AutoIt functions the code will be very fast. All Microsoft functions can be used this way eg. functions for event handling. New interfaces, objects, methods, properties and constants can easily be added simply by adding the definitions to CUIAutomation2.au3. Is this approach difficult? Not at all as the examples will show. The example is inspired by this comment of mLipok. Including documentation and pictures, even a simple Notepad automation can be somewhat comprehensive. Therefore a new example. First post will be a list of examples. The examples themselves are reviewed in the following posts. In all examples UIASpy is used to get element information. Topics Using UIASpy UIASpy thread Automating Notepad. Very detailed example. Automating Notepad with Sample code - step by step Automating Notepad with Sample code - all at once Automating Notepad - Windows XP Automating Notepad - Classic Click Save As... issue Automating Notepad context menu. Event handler example. Chrome - Clicking an extension. Compact summary example. Other spy tools Using Microsoft Inspect.exe simplespy.au3 by junkew How to topics If UI Automation or the UIASpy tool is new to you, then you should start reading the How to topics Various topics Console and terminal windows Console application (3 posts) Terminal program (several posts) Examples Patterns (actions) Code snippets Real examples UIA updates UIA events Threads UI Automation UDFs contains all include files. 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. 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 files for all examples. Note that UI Automation UDFs must be installed in the Includes folder. You need AutoIt 3.3.12 or later. Tested on Windows XP, Windows 7 and Windows 10. Comments and questions about using UIA code are welcome. Let me know if there are any issues. Questions about the functions in UIAWrappers.au3 should be asked in junkew's thread. UIAExamples.7z1 point
-
1 point
-
Right click in a resizable control
pixelsearch reacted to Nine for a topic
Your dock resizing is not working correctly. Use instead : GUICtrlSetResizing(-1, $GUI_DOCKAUTO)1 point -
Right click in a resizable control
pixelsearch reacted to mistersquirrle for a topic
I added a little logging, and what I found was that at a certain width, you stopped right clicking on the Edit control, and were instead clicking on the Tab control: ; https://www.autoitscript.com/forum/topic/209667-right-click-in-a-resizable-control/ #include <GUIConstants.au3> #include <MsgBoxConstants.au3> #include <GuiTab.au3> Global $hGUI = GUICreate("Test right click", 460, 598, -1, -1, _ BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX)) Global $aGUIInitPos = WinGetPos($hGUI) ; see Func WM_GETMINMAXINFO $grpExpressions = GUICtrlCreateGroup("", 4, 156, 449, 145, -1, $WS_EX_TRANSPARENT) ConsoleWrite('$grpExpressions: ' & $grpExpressions & @CRLF) $tabExpr = GUICtrlCreateTab(8, 174, 442, 121, BitOR($TCS_BUTTONS, $TCS_FLATBUTTONS, $TCS_FOCUSONBUTTONDOWN)) ConsoleWrite('$tabExpr: ' & $tabExpr & @CRLF) GUICtrlSetFont(-1, 8, 400, 0, "MS Sans Serif") GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT) $TabSheet0 = GUICtrlCreateTabItem("Search Pattern") ConsoleWrite('$TabSheet0: ' & $TabSheet0 & @CRLF) $ebRegExp = GUICtrlCreateEdit("", 12, 201, 434, 90, BitOR($ES_WANTRETURN,$WS_VSCROLL)) ConsoleWrite('$ebRegExp: ' & $ebRegExp & @CRLF) GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console") GUICtrlSetBkColor(-1, 0xCCFFFF) ; light blue ;~ GUICtrlSetResizing(-1, $GUI_DOCKBORDERS) $TabSheet1 = GUICtrlCreateTabItem("Replace Pattern") ConsoleWrite('$TabSheet1: ' & $TabSheet1 & @CRLF) $ebRegExpReplace = GUICtrlCreateEdit("", 12, 201, 434, 90, BitOR($ES_WANTRETURN,$WS_VSCROLL)) ConsoleWrite('$tabExpr: ' & $tabExpr & @CRLF) GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console") $TabSheet2 = GUICtrlCreateTabItem("Result Prefix") ConsoleWrite('$TabSheet2: ' & $TabSheet2 & @CRLF) $ebResultPrefix = GUICtrlCreateEdit("", 12, 201, 434, 90, BitOR($ES_WANTRETURN,$WS_VSCROLL)) ConsoleWrite('$ebResultPrefix: ' & $ebResultPrefix & @CRLF) GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console") $TabSheet3 = GUICtrlCreateTabItem("Result Suffix") ConsoleWrite('$TabSheet3: ' & $TabSheet3 & @CRLF) $ebResultSuffix = GUICtrlCreateEdit("", 12, 201, 434, 90, BitOR($ES_WANTRETURN,$WS_VSCROLL)) ConsoleWrite('$ebResultSuffix: ' & $ebResultSuffix & @CRLF) GUICtrlSetFont(-1, 11, 400, 0, "Lucida Console") GUICtrlCreateTabItem("") GUICtrlCreateGroup("", -99, -99, 1, 1) $lblDummy = GUICtrlCreateLabel("", 336, 552, 1, 1) ; 1 pixel size ! Good luck to click on it in the GUI :) $lblDummycontext = GUICtrlCreateContextMenu($lblDummy) $hDummycontext = GUICtrlGetHandle($lblDummyContext) ; for function _TrackPopupMenu() $mnu0200 = GUICtrlCreateMenu("Matching Characters", $lblDummycontext) GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO") GUISetState(@SW_SHOW) Local $aInfo, $mPos, $aEditPos, $iRclick_count = 0 While 1 $aInfo = GUIGetCursorInfo() If IsArray($aInfo) Then If $aInfo[3] = 1 Then ; right click Select Case $aInfo[4] = $ebRegExp ; no problem when hovering "match text" edit control $ebRegExp (in its original size) $mPos = MouseGetPos() _TrackPopupMenu($hGUI, $hDummycontext, $mPos[0], $mPos[1]) Case BitAND(WinGetState($hGUI), $WIN_STATE_MAXIMIZED) = $WIN_STATE_MAXIMIZED ; conditions to display context help menu change a lot if maximized If $aInfo[4] = $tabExpr And _GUICtrlTab_GetCurSel($tabExpr) = 0 Then ; 0 = 1st Tab (Search Pattern) $iRclick_count += 1 ; 1+ If $iRclick_count = 1 Then $aEditPos = WinGetPos(GUICtrlGetHandle($ebRegExp)) ; ckeck only once (GUI is maximized) $mPos = MouseGetPos() If $mPos[0] > $aEditPos[0] _ And $mPos[1] > $aEditPos[1] _ And $mPos[0] < $aEditPos[0] + $aEditPos[2] _ And $mPos[1] < $aEditPos[1] + $aEditPos[3] Then _TrackPopupMenu($hGUI, $hDummycontext, $mPos[0], $mPos[1]) EndIf EndIf Case Else ConsoleWrite($aInfo[4] & @CRLF) EndSelect EndIf EndIf $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd ;==================================================== Func _TrackPopupMenu($hWnd, $hMenu, $x, $y) DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0) EndFunc ;==================================================== Func WM_GETMINMAXINFO($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $wParam If $hWnd = $hGUI Then Local $minmaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam) DllStructSetData($minmaxinfo, 7, $aGUIInitPos[2]) ; min width DllStructSetData($minmaxinfo, 8, $aGUIInitPos[3]) ; min height Return 0 ; "If an application processes this message, it should return zero." (msdn) EndIf Return $GUI_RUNDEFMSG EndFunc So changing this line: $tabExpr = GUICtrlCreateTab(8, 174, 442, 121, BitOR($TCS_BUTTONS, $TCS_FLATBUTTONS, $TCS_FOCUSONBUTTONDOWN)) To a height value that wouldn't extend down into the Edit prevented it from basically being 'over' the edit: $tabExpr = GUICtrlCreateTab(8, 174, 442, 21, BitOR($TCS_BUTTONS, $TCS_FLATBUTTONS, $TCS_FOCUSONBUTTONDOWN)) Another option would probably be to get the ControlGetPos and do your own calc for if you're over the edit box. I'm not sure why the ordering switches at a certain size.1 point -
Is there a way to send copy , no matter what language I have active?
mistersquirrle reacted to ioa747 for a topic
@mistersquirrle to share my joy !! #include <WinAPISys.au3> sKey("^c") ConsoleWrite(ClipGet() & @CRLF) ;---------------------------------------------------------------------------------------- Func sKey($sKey, $iCnt = 1, $iDelay = 50) ; English (United States) 0x0409, 0x04090409 Local $Lang, $hWnd = WinGetHandle("[ACTIVE]") $Lang = _WinAPI_GetKeyboardLayout($hWnd) If $Lang <> "0x04090409" Then ; if not English then make it _WinAPI_SetKeyboardLayout($hWnd, "0x0409") EndIf For $i = 1 To $iCnt Step 1 Send($sKey) Sleep($iDelay) Next If $Lang <> "0x04090409" Then ; If was others of English set it back _WinAPI_SetKeyboardLayout($hWnd, '0x' & StringRight($Lang, 4)) EndIf EndFunc ;==>sKey ;----------------------------------------------------------------------------------------1 point -
Implementing Virtual TreeViews
argumentum reacted to LarsJ for a topic
Virtual TreeView functions These are, for now, the last functions directly concentrated on handling TreeView source files. Some of the functions are also implemented in VB.NET code. All code located in Examples\Part 2\3) Virtual TreeView Functions. Run the examples in SciTE with F5. TVSourceFile.au3 (Includes\TVSourceFile.au3) This is the updated function list at top of file: ; Functions ; ------------------------------------- ; TVSourceCreateVbNetCodeObject() Create $oVbNetCode object to execute treeview source file functions as compiled VB.NET code ; ; TVSourceCreatePlain() Create random plain source file for non-virtual treeview ; TVSourceCreatePlainDbg() Create random plain source file for non-virtual treeview. Debug version. ; TVSourceCreatePlainEx() Based on recursive function with support for 100 levels ; TVSourceCreatePlainExVb() Based on recursive function with support for 100 levels. VB.NET code. ; TVSourceCreatePlainExDbg() Based on recursive function with support for 100 levels. Debug version. ; TVSourceCreatePlainExDbgVb() Based on recursive function with support for 100 levels. Debug version. VB.NET code. ; TVSourceCreatePlainExConst() Create constant plain source file for non-virtual treeview. Debug version. Constant source file. ; TVSourceCreatePlainExConstVb() Create constant plain source file for non-virtual treeview. Debug version. Constant source file. VB.NET code. ; TVSourceCreatePlainExConstCount() Count number of treeview items generated by TVSourceCreatePlainExConst/Vb() above ; TVSourceCreatePlainExConstCountVb() Count number of treeview items generated by TVSourceCreatePlainExConst/Vb() above. VB.NET code. ; TVSourceCreateVirtual() Create random source file for virtual treeview ; TVSourceCreateVirtualDbg() Create random source file for virtual treeview. Debug version. Contains code comments. <<<<<<<<<< ; ; TVSourceCountPlainLevels() Count number of levels in plain treeview source file ; TVSourceCountPlainLevelsVb() Count number of levels in plain treeview source file. VB.NET code. ; TVSourceCountSubtreeItems() Count number of subtree items in plain/virtual treeview source file ; TVSourceCountSubtreeItemsVb() Count number of subtree items in plain/virtual treeview source file. VB.NET code. ; ; TVSourceConvertPlainToVirtual() Convert plain source file for non-virtual treeview to source file for virtual treeview ; TVSourceConvertPlainToVirtualVb() Convert plain source file for non-virtual treeview to source file for virtual treeview. VB.NET code. ; TVSourceConvertVirtualToPlain() Convert source file for virtual treeview to plain source file for non-virtual treeview ; ; TVSourceExtractSubtreeFromPlain() Extract plain subtree source file from plain treeview source file ; TVSourceExtractSubtreeFromPlainVb() Extract plain subtree source file from plain treeview source file. VB.NET code. ; TVSourceExtractSubtreeFromVirtual() Extract plain subtree source file from virtual treeview source file ; TVSourceExtractSubtreeFromVirtualVb() Extract plain subtree source file from virtual treeview source file. VB.NET code. ; ; TVSourceGetParentsFromVirtual() Get parents from root to item in true virtual source file ; ; TVSourceDisplayPlain() Display non-virtual treeview from plain source file ; TVSourceDisplayVirtual() Display virtual treeview from source file The new functions are the Count and Extract functions and TVSourceGetParentsFromVirtual(). Optionally collapse the first root node in the CountSubtreeItems and plain Extract examples. Then item 3432 becomes visible, which is the start item in these examples. New 7z-file at bottom of first post.1 point -
Can't exit Node-Red (in console window) with CTRL+C
lee321987 reacted to mistersquirrle for a topic
I think that this is an issue with how running an uncompiled script works in AutoIt. You can test the issue with this: #include <AutoItConstants.au3> Local $iPid = Run(@ComSpec & ' /k ping 127.0.0.1 -t ', '', @SW_SHOW, $RUN_CREATE_NEW_CONSOLE) If you run that from SciTE and try to do Ctrl + c to cancel it, or Ctrl + BREAK, neither work and the ping continues. However, if you set the flag #AutoIt3Wrapper_Change2CUI=y And then compile the script and run it, you ARE able to cancel it with Ctrl + c. So I think that if you're looking for that Ctrl + c functionality, just keep in mind that you'll need to compile the script to get it. Here's my full test: #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseUpx=y #AutoIt3Wrapper_UseX64=y #AutoIt3Wrapper_Change2CUI=y #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include-once #include <AutoItConstants.au3> Local $iPid = Run(@ComSpec & ' /k ping 127.0.0.1 -t ', '', @SW_SHOW, $RUN_CREATE_NEW_CONSOLE)1 point -
AutoIt Cheat Sheet
AutoBert reacted to JLogan3o13 for a topic
There is already an official Wiki, why would you not just direct new people here rather than adding confusion by having to maintain two sources?1 point -
Is there a way to send copy , no matter what language I have active?
ioa747 reacted to mistersquirrle for a topic
That is very interesting... I'd be curious to know why these codes work. When I look at an ASCII table, it says 003 = "End of Text". I don't quite understand why/how this translates to 'Copy' when sent with Send. I did a test to find what Paste would be, and it looks like that it's: 022 = "Device control 2, block-mode flow control". Also, I'd be careful as this functionality doesn't appear to work in any/all windows, in fact for the most part it only appears to work for me in the AutoIt GUI and 'standard' or older Windows programs. Here's what I used to test and find copy/paste from your example: #include <GUIConstantsEx.au3> #include <EditConstants.au3> Local $sCopy = 'ASC 003', $sPaste = 'ASC 022' HotKeySet('[', __Copy) HotKeySet(']', __Paste) HotKeySet('{END}', __Exit) Example() Func Example() GUICreate("My GUI", 320, 120) Local $idFile = GUICtrlCreateInput("Woof", 10, 5, 300, 20, $ES_READONLY) Local $idFile2 = GUICtrlCreateInput("", 10, 35, 300, 20) Local $idBtnCopy = GUICtrlCreateButton("Copy", 40, 75, 60, 20) Local $idBtnScanCopy = GUICtrlCreateButton("ScanCopy", 110, 75, 60, 20) Local $idBtnScanPaste = GUICtrlCreateButton("ScanPaste", 180, 75, 60, 20) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $idBtnCopy ControlFocus("My GUI", "", $idFile) Sleep(100) ConsoleWrite(ClipGet() & @CRLF) Case $idBtnScanCopy ControlFocus("My GUI", "", $idFile) ClipPut('Meow') For $i = 0 To 377 ConsoleWrite('Trying: ' & '{ASC ' & StringFormat('%03i', $i) & '}' & @CRLF) Send('{ASC ' & StringFormat('%03i', $i) & '}') If StringCompare(ClipGet(), 'Woof', 0) = 0 Then ConsoleWrite('Found a copy code at ' & $i & ', ' & ClipGet() & @CRLF) ExitLoop EndIf Next Case $idBtnScanPaste GUICtrlSetData($idFile2, '') ControlFocus("My GUI", "", $idFile2) ClipPut('Meow') For $i = 0 To 377 ConsoleWrite('Trying: ' & '{ASC ' & StringFormat('%03i', $i) & '}' & @CRLF) Send('{ASC ' & StringFormat('%03i', $i) & '}') If StringInStr(GUICtrlRead($idFile2), 'Meow') > 0 Then ConsoleWrite('Found a paste code at ' & $i & ', ' & ClipGet() & @CRLF) ExitLoop EndIf Next EndSwitch WEnd EndFunc ;==>Example Func __Copy() Local $sMsg = '' $sMsg = 'Copying, current: ' & StringLeft(StringRegExpReplace(ClipGet(), @CRLF & '|' & @CR & '|' & @LF, ''), 100) & ', new: ' Send('{' & $sCopy & '}') $sMsg &= ClipGet() ;~ __cLog($sMsg) ConsoleWrite($sMsg & @CRLF) EndFunc ;==>__Copy Func __Paste() ;~ __cLog('Pasting') ConsoleWrite('Pasting' & @CRLF) Send('{' & $sPaste & '}') EndFunc ;==>__Paste Func __Exit() Exit EndFunc ;==>__Exit I added hotkeys for [ and ] for copy and paste. It works fine in the AutoIt GUI, but in SciTE and Chrome it didn't work. SciTE inserted EXT and SYN, and Chrome did nothing. Notepad did however accept the copy/paste just fine. Also worked in Explorer and the older Windows Calculator (but not the newer one). If these codes work for whatever you're up to, then great, but it's not a solve all it looks like.1 point -
How to know when AutoIT is done sending text?
pixelsearch reacted to ioa747 for a topic
for shorter interaction time copy to clipboard first and then paste1 point -
Automating Notepad This example is a response to a request by mLipok for a simple Notepad automation. Task: Create a simple script to fill up "Edit1" with HelloWorld, click "Save As...", enter filename and finally save it to disc. This involves automating Notepad or more generally an Edit control, it involves automating a menu and a Save As dialog. Note that "Edit1" (from AutoIt Window Info tool) is not a valid control identification in UI Automation code. Do not open Notepad in advance. This will be done in the code. Start the code by opening Notepad and create the UI Automation object through IUIAutomation interface. I almost always create the Desktop element. Note how you first get a pointer to the element (GetRootElement method of $oUIAutomation object), and then creates the object that represents the element through IUIAutomationElement interface. UI Automation elements are nearly always created this way through a pointer. #include "..\..\Includes\CUIAutomation2.au3" Example() Func Example() ; Open Notepad Run( "Notepad" ) Sleep( 1000 ) ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) 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, $dtagIUIAutomationElement ) If Not IsObj( $oDesktop ) Then Return ConsoleWrite( "$oDesktop ERR" & @CRLF ) ConsoleWrite( "$oDesktop OK" & @CRLF ) EndFunc Open Examples\Notepad\Notepad.au3 (empty) in SciTE. Add the code, run the code with F5 and leave Notepad open. Check that SciTE output is OK. Next step is to get the Notepad window as an UI Automation element. Open UIASpy (included in zip-file, keep UIASpy open throughout the entire example), place mouse cursor over Notepad title bar and press F2: (You can delete other windows in UIASpy by right-clicking treeview top windows (level one items).) $UIA_ClassNamePropertyId = "Notepad" is used to create a property condition to identify Notepad. Note that you can copy this line in UIASpy listview: Select the line in the listview, click "Right pane" item in main menu, click "Copy all or selected items to clipboard", paste the line into your code editor. Add this code to the existing code: ; --- Notepad window --- ConsoleWrite( "--- Notepad window ---" & @CRLF ) Local $pCondition ; Note that $UIA_ClassNamePropertyId maybe ia a CASE SENSITIVE condition $oUIAutomation.CreatePropertyCondition( $UIA_ClassNamePropertyId, "Notepad", $pCondition ) If Not $pCondition Then Return ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) Local $pNotepad, $oNotepad $oDesktop.FindFirst( $TreeScope_Descendants, $pCondition, $pNotepad ) $oNotepad = ObjCreateInterface( $pNotepad, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oNotepad ) Then Return ConsoleWrite( "$oNotepad ERR" & @CRLF ) ConsoleWrite( "$oNotepad OK" & @CRLF ) EndFunc Note again how we first get a pointer to Notepad (FindFirst method of $oDesktop object, $oDesktop because the Desktop is the parent element of Notepad) and then creates the object. Also note that $oDesktop and $oNotepad are created in exactly the same way. Close the previous Notepad, run the code and leave Notepad open. Check that SciTE output is OK. Now, the actual automation starts: Fill up "Edit1" with HelloWorld. An automation task is almost always done in two or three steps: 1. Create condition to find element 2. Find the UI Automation element 3. Extract info or perform action Each of these steps can usually be done in 1 - 3 lines of UI Automation code. All three steps can usually be done in less that 10 lines of UI Automation code (common AutoIt debug/info code not included). To get the Notepad window above we only used two steps. The first automation task is to perform an action to fill out the Edit control with "HelloWorld". Place mouse cursor in the Edit control and press F1: (If there are two or more Notepad windows in UIASpy, you can delete the old windows (red) by right-clicking the treeview.) This time we can use $UIA_AutomationIdPropertyId = "15" to create a property condition to identify the Edit control. Add this code: ; --- Fill Edit element --- ConsoleWrite( "--- Fill Edit element ---" & @CRLF ) ; Note that $UIA_AutomationIdPropertyId is a STRING and maybe a CASE SENSITIVE condition $oUIAutomation.CreatePropertyCondition( $UIA_AutomationIdPropertyId, "15", $pCondition ) If Not $pCondition Then Return ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) Local $pEdit, $oEdit $oNotepad.FindFirst( $TreeScope_Descendants, $pCondition, $pEdit ) $oEdit = ObjCreateInterface( $pEdit, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oEdit ) Then Return ConsoleWrite( "$oEdit ERR" & @CRLF ) ConsoleWrite( "$oEdit OK" & @CRLF ) EndFunc $oNotepad.FindFirst means that the search for the Edit control starts in the Notepad window. $oEdit reprecents the Edit control. Close the previous Notepad, run the code and leave Notepad open. Check that SciTE output is OK. The Edit control must be filled with "HelloWorld". This is an action that has to be performed on the Edit control. The following actions are available: (Scroll down UIASpy listview to see Control Patterns (actions).) The interesting action or pattern here is the ValuePattern. The action is created and performed this way: Local $pValue, $oValue $oEdit.GetCurrentPattern( $UIA_ValuePatternId, $pValue ) $oValue = ObjCreateInterface( $pValue, $sIID_IUIAutomationValuePattern, $dtagIUIAutomationValuePattern ) If Not IsObj( $oValue ) Then Return ConsoleWrite( "$oValue ERR" & @CRLF ) ConsoleWrite( "$oValue OK" & @CRLF ) $oValue.SetValue( "HelloWorld" ) EndFunc $oEdit.GetCurrentPattern means that a pattern is created that performs actions on the Edit control. GetCurrentPattern method returns a pointer where from the ValuePattern object ($oValue) can be created. $UIA_ValuePatternId and the ValuePattern interface is defined in CUIAutomation2.au3. The $oValue object represents the ValuePattern interface for the Edit control. $oValue.SetValue( "HelloWorld" ) sets the text in the Edit control. An action or pattern is almost always created and performed this way. Add the code, close the previous Notepad, run the code and leave Notepad open. Open File menu. Place mouse cursor over the File menu and press F1: (Scroll down UIASpy listview to see Control Patterns (actions) in bottom of image.) ; --- Open File menu --- ConsoleWrite( "--- Open File menu ---" & @CRLF ) Local $pCondition1 $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_MenuItemControlTypeId, $pCondition1 ) If Not $pCondition1 Then Return ConsoleWrite( "$pCondition1 ERR" & @CRLF ) ConsoleWrite( "$pCondition1 OK" & @CRLF ) Local $pCondition2 ; $UIA_NamePropertyId is LOCALIZED and maybe CASE SENSITIVE $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "File", $pCondition2 ) ; File <<<<<<<<<<<<<<<<<<<< If Not $pCondition2 Then Return ConsoleWrite( "$pCondition2 ERR" & @CRLF ) ConsoleWrite( "$pCondition2 OK" & @CRLF ) ; And condition $oUIAutomation.CreateAndCondition( $pCondition1, $pCondition2, $pCondition ) If Not $pCondition Then Return ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) Local $pFile, $oFile $oNotepad.FindFirst( $TreeScope_Descendants, $pCondition, $pFile ) $oFile = ObjCreateInterface( $pFile, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oFile ) Then Return ConsoleWrite( "$oFile ERR" & @CRLF ) ConsoleWrite( "$oFile OK" & @CRLF ) Local $pInvoke, $oInvoke $oFile.GetCurrentPattern( $UIA_InvokePatternId, $pInvoke ) $oInvoke = ObjCreateInterface( $pInvoke, $sIID_IUIAutomationInvokePattern, $dtagIUIAutomationInvokePattern ) If Not IsObj( $oInvoke ) Then Return ConsoleWrite( "$oInvoke ERR" & @CRLF ) ConsoleWrite( "$oInvoke OK" & @CRLF ) $oInvoke.Invoke() Sleep( 100 ) EndFunc The Invoke action or pattern is used to click and open the File menu. Note the similarity between the code for InvokePattern and ValuePattern above. When a menu, dialog box or child window is opened it need some time to open. You must add a Sleep statement. Add the code, change "File" to the corresponding word in your own language (copy the word from the listview), close the previous Notepad (don't save), run the code and leave Notepad open. Click "Save As..." menu. If the File menu that was opened above is closed, then open it manually with a mouse click. Place mouse cursor over the "Save As..." menu and press F1: ; --- Click "Save As..." menu --- ConsoleWrite( "--- Click ""Save As..."" menu ---" & @CRLF ) ; Reuse $pCondition1 above ; Note that $UIA_AutomationIdPropertyId is a STRING and maybe a CASE SENSITIVE condition $oUIAutomation.CreatePropertyCondition( $UIA_AutomationIdPropertyId, "4", $pCondition2 ) If Not $pCondition2 Then Return ConsoleWrite( "$pCondition2 ERR" & @CRLF ) ConsoleWrite( "$pCondition2 OK" & @CRLF ) ; And condition $oUIAutomation.CreateAndCondition( $pCondition1, $pCondition2, $pCondition ) If Not $pCondition Then Return ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) Local $pSaveAs, $oSaveAs $oNotepad.FindFirst( $TreeScope_Descendants, $pCondition, $pSaveAs ) $oSaveAs = ObjCreateInterface( $pSaveAs, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oSaveAs ) Then Return ConsoleWrite( "$oSaveAs ERR" & @CRLF ) ConsoleWrite( "$oSaveAs OK" & @CRLF ) $oSaveAs.GetCurrentPattern( $UIA_InvokePatternId, $pInvoke ) $oInvoke = ObjCreateInterface( $pInvoke, $sIID_IUIAutomationInvokePattern, $dtagIUIAutomationInvokePattern ) If Not IsObj( $oInvoke ) Then Return ConsoleWrite( "$oInvoke ERR" & @CRLF ) ConsoleWrite( "$oInvoke OK" & @CRLF ) $oInvoke.Invoke() Sleep( 1000 ) EndFunc Note how similar the "Open File menu" code and the "Click Save As... menu" code is. Note also the long Sleep because it's a "Save As" dialog with a large number of elements. Add the code, close the previous Notepad (don't save), run the code and leave Notepad and Save As open. Save As window. Place mouse cursor over Save As title bar and press F2: ; --- Save As window --- ConsoleWrite( "--- Save As window ---" & @CRLF ) ; Note that $UIA_ClassNamePropertyId maybe ia a CASE SENSITIVE condition $oUIAutomation.CreatePropertyCondition( $UIA_ClassNamePropertyId, "#32770", $pCondition ) If Not $pCondition Then Return ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) Local $pSaveAsWin, $oSaveAsWin $oNotepad.FindFirst( $TreeScope_Descendants, $pCondition, $pSaveAsWin ) $oSaveAsWin = ObjCreateInterface( $pSaveAsWin, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oSaveAsWin ) Then Return ConsoleWrite( "$oSaveAsWin ERR" & @CRLF ) ConsoleWrite( "$oSaveAsWin OK" & @CRLF ) EndFunc The rest of the automation tasks is about the Save As window. Therefore we want to use the Save As window as the starting point. Not Notepad. Add the code, close the previous Save As and Notepad (don't save), run the code and leave Notepad and Save As open. Set File name. Place mouse cursor over File name Edit control and press F1: ; --- Set File name --- ConsoleWrite( "--- Set File name ---" & @CRLF ) ; Note that $UIA_AutomationIdPropertyId is a STRING and maybe a CASE SENSITIVE condition $oUIAutomation.CreatePropertyCondition( $UIA_AutomationIdPropertyId, "1001", $pCondition ) If Not $pCondition Then Return ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) $oSaveAsWin.FindFirst( $TreeScope_Descendants, $pCondition, $pEdit ) $oEdit = ObjCreateInterface( $pEdit, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oEdit ) Then Return ConsoleWrite( "$oEdit ERR" & @CRLF ) ConsoleWrite( "$oEdit OK" & @CRLF ) $oEdit.GetCurrentPattern( $UIA_ValuePatternId, $pValue ) $oValue = ObjCreateInterface( $pValue, $sIID_IUIAutomationValuePattern, $dtagIUIAutomationValuePattern ) If Not IsObj( $oValue ) Then Return ConsoleWrite( "$oValue ERR" & @CRLF ) ConsoleWrite( "$oValue OK" & @CRLF ) $oValue.SetValue( "HelloWorld.txt" ) EndFunc $oSaveAsWin.FindFirst searches in the Save As window. $oEdit is now the File name Edit control in the Save As window. The file name is set to "HelloWorld.txt". Add the code, close the previous Save As and Notepad (don't save), run the code and leave Notepad and Save As open. Click Save button. Place mouse cursor over Save button and press F1: ; --- Click Save button --- ConsoleWrite( "--- Click Save button ---" & @CRLF ) $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_ButtonControlTypeId, $pCondition1 ) If Not $pCondition1 Then Return ConsoleWrite( "$pCondition1 ERR" & @CRLF ) ConsoleWrite( "$pCondition1 OK" & @CRLF ) ; Note that $UIA_AutomationIdPropertyId is a STRING and maybe a CASE SENSITIVE condition $oUIAutomation.CreatePropertyCondition( $UIA_AutomationIdPropertyId, "1", $pCondition2 ) If Not $pCondition2 Then Return ConsoleWrite( "$pCondition2 ERR" & @CRLF ) ConsoleWrite( "$pCondition2 OK" & @CRLF ) ; And condition $oUIAutomation.CreateAndCondition( $pCondition1, $pCondition2, $pCondition ) If Not $pCondition Then Return ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) Local $pSave, $oSave $oSaveAsWin.FindFirst( $TreeScope_Descendants, $pCondition, $pSave ) $oSave = ObjCreateInterface( $pSave, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oSave ) Then Return ConsoleWrite( "$oSave ERR" & @CRLF ) ConsoleWrite( "$oSave OK" & @CRLF ) $oSave.GetCurrentPattern( $UIA_InvokePatternId, $pInvoke ) $oInvoke = ObjCreateInterface( $pInvoke, $sIID_IUIAutomationInvokePattern, $dtagIUIAutomationInvokePattern ) If Not IsObj( $oInvoke ) Then Return ConsoleWrite( "$oInvoke ERR" & @CRLF ) ConsoleWrite( "$oInvoke OK" & @CRLF ) $oInvoke.Invoke() EndFunc Add the code, close the previous Save As and Notepad (don't save) and run the code. All code (Examples\Notepad\NotepadAll.au3): #include "..\..\Includes\CUIAutomation2.au3" Example() Func Example() ; Open Notepad Run( "Notepad" ) Sleep( 1000 ) ; Create UI Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) 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, $dtagIUIAutomationElement ) If Not IsObj( $oDesktop ) Then Return ConsoleWrite( "$oDesktop ERR" & @CRLF ) ConsoleWrite( "$oDesktop OK" & @CRLF ) ; --- Notepad window --- ConsoleWrite( "--- Notepad window ---" & @CRLF ) Local $pCondition ; Note that $UIA_ClassNamePropertyId maybe ia a CASE SENSITIVE condition $oUIAutomation.CreatePropertyCondition( $UIA_ClassNamePropertyId, "Notepad", $pCondition ) If Not $pCondition Then Return ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) Local $pNotepad, $oNotepad $oDesktop.FindFirst( $TreeScope_Descendants, $pCondition, $pNotepad ) $oNotepad = ObjCreateInterface( $pNotepad, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oNotepad ) Then Return ConsoleWrite( "$oNotepad ERR" & @CRLF ) ConsoleWrite( "$oNotepad OK" & @CRLF ) ; --- Fill Edit element --- ConsoleWrite( "--- Fill Edit element ---" & @CRLF ) ; Note that $UIA_AutomationIdPropertyId is a STRING and maybe a CASE SENSITIVE condition $oUIAutomation.CreatePropertyCondition( $UIA_AutomationIdPropertyId, "15", $pCondition ) If Not $pCondition Then Return ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) Local $pEdit, $oEdit $oNotepad.FindFirst( $TreeScope_Descendants, $pCondition, $pEdit ) $oEdit = ObjCreateInterface( $pEdit, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oEdit ) Then Return ConsoleWrite( "$oEdit ERR" & @CRLF ) ConsoleWrite( "$oEdit OK" & @CRLF ) Local $pValue, $oValue $oEdit.GetCurrentPattern( $UIA_ValuePatternId, $pValue ) $oValue = ObjCreateInterface( $pValue, $sIID_IUIAutomationValuePattern, $dtagIUIAutomationValuePattern ) If Not IsObj( $oValue ) Then Return ConsoleWrite( "$oValue ERR" & @CRLF ) ConsoleWrite( "$oValue OK" & @CRLF ) $oValue.SetValue( "HelloWorld" ) ; --- Open File menu --- ConsoleWrite( "--- Open File menu ---" & @CRLF ) Local $pCondition1 $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_MenuItemControlTypeId, $pCondition1 ) If Not $pCondition1 Then Return ConsoleWrite( "$pCondition1 ERR" & @CRLF ) ConsoleWrite( "$pCondition1 OK" & @CRLF ) Local $pCondition2 ; $UIA_NamePropertyId is LOCALIZED and maybe CASE SENSITIVE $oUIAutomation.CreatePropertyCondition( $UIA_NamePropertyId, "File", $pCondition2 ) ; File <<<<<<<<<<<<<<<<<<<< If Not $pCondition2 Then Return ConsoleWrite( "$pCondition2 ERR" & @CRLF ) ConsoleWrite( "$pCondition2 OK" & @CRLF ) ; And condition $oUIAutomation.CreateAndCondition( $pCondition1, $pCondition2, $pCondition ) If Not $pCondition Then Return ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) Local $pFile, $oFile $oNotepad.FindFirst( $TreeScope_Descendants, $pCondition, $pFile ) $oFile = ObjCreateInterface( $pFile, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oFile ) Then Return ConsoleWrite( "$oFile ERR" & @CRLF ) ConsoleWrite( "$oFile OK" & @CRLF ) Local $pInvoke, $oInvoke $oFile.GetCurrentPattern( $UIA_InvokePatternId, $pInvoke ) $oInvoke = ObjCreateInterface( $pInvoke, $sIID_IUIAutomationInvokePattern, $dtagIUIAutomationInvokePattern ) If Not IsObj( $oInvoke ) Then Return ConsoleWrite( "$oInvoke ERR" & @CRLF ) ConsoleWrite( "$oInvoke OK" & @CRLF ) $oInvoke.Invoke() Sleep( 100 ) ; --- Click "Save As..." menu --- ConsoleWrite( "--- Click ""Save As..."" menu ---" & @CRLF ) ; Reuse $pCondition1 above ; Note that $UIA_AutomationIdPropertyId is a STRING and maybe a CASE SENSITIVE condition $oUIAutomation.CreatePropertyCondition( $UIA_AutomationIdPropertyId, "4", $pCondition2 ) If Not $pCondition2 Then Return ConsoleWrite( "$pCondition2 ERR" & @CRLF ) ConsoleWrite( "$pCondition2 OK" & @CRLF ) ; And condition $oUIAutomation.CreateAndCondition( $pCondition1, $pCondition2, $pCondition ) If Not $pCondition Then Return ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) Local $pSaveAs, $oSaveAs $oNotepad.FindFirst( $TreeScope_Descendants, $pCondition, $pSaveAs ) $oSaveAs = ObjCreateInterface( $pSaveAs, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oSaveAs ) Then Return ConsoleWrite( "$oSaveAs ERR" & @CRLF ) ConsoleWrite( "$oSaveAs OK" & @CRLF ) $oSaveAs.GetCurrentPattern( $UIA_InvokePatternId, $pInvoke ) $oInvoke = ObjCreateInterface( $pInvoke, $sIID_IUIAutomationInvokePattern, $dtagIUIAutomationInvokePattern ) If Not IsObj( $oInvoke ) Then Return ConsoleWrite( "$oInvoke ERR" & @CRLF ) ConsoleWrite( "$oInvoke OK" & @CRLF ) $oInvoke.Invoke() Sleep( 1000 ) ; --- Save As window --- ConsoleWrite( "--- Save As window ---" & @CRLF ) ; Note that $UIA_ClassNamePropertyId maybe ia a CASE SENSITIVE condition $oUIAutomation.CreatePropertyCondition( $UIA_ClassNamePropertyId, "#32770", $pCondition ) If Not $pCondition Then Return ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) Local $pSaveAsWin, $oSaveAsWin $oNotepad.FindFirst( $TreeScope_Descendants, $pCondition, $pSaveAsWin ) $oSaveAsWin = ObjCreateInterface( $pSaveAsWin, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oSaveAsWin ) Then Return ConsoleWrite( "$oSaveAsWin ERR" & @CRLF ) ConsoleWrite( "$oSaveAsWin OK" & @CRLF ) ; --- Set File name --- ConsoleWrite( "--- Set File name ---" & @CRLF ) ; Note that $UIA_AutomationIdPropertyId is a STRING and maybe a CASE SENSITIVE condition $oUIAutomation.CreatePropertyCondition( $UIA_AutomationIdPropertyId, "1001", $pCondition ) If Not $pCondition Then Return ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) $oSaveAsWin.FindFirst( $TreeScope_Descendants, $pCondition, $pEdit ) $oEdit = ObjCreateInterface( $pEdit, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oEdit ) Then Return ConsoleWrite( "$oEdit ERR" & @CRLF ) ConsoleWrite( "$oEdit OK" & @CRLF ) $oEdit.GetCurrentPattern( $UIA_ValuePatternId, $pValue ) $oValue = ObjCreateInterface( $pValue, $sIID_IUIAutomationValuePattern, $dtagIUIAutomationValuePattern ) If Not IsObj( $oValue ) Then Return ConsoleWrite( "$oValue ERR" & @CRLF ) ConsoleWrite( "$oValue OK" & @CRLF ) $oValue.SetValue( "HelloWorld.txt" ) ; --- Click Save button --- ConsoleWrite( "--- Click Save button ---" & @CRLF ) $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_ButtonControlTypeId, $pCondition1 ) If Not $pCondition1 Then Return ConsoleWrite( "$pCondition1 ERR" & @CRLF ) ConsoleWrite( "$pCondition1 OK" & @CRLF ) ; Note that $UIA_AutomationIdPropertyId is a STRING and maybe a CASE SENSITIVE condition $oUIAutomation.CreatePropertyCondition( $UIA_AutomationIdPropertyId, "1", $pCondition2 ) If Not $pCondition2 Then Return ConsoleWrite( "$pCondition2 ERR" & @CRLF ) ConsoleWrite( "$pCondition2 OK" & @CRLF ) ; And condition $oUIAutomation.CreateAndCondition( $pCondition1, $pCondition2, $pCondition ) If Not $pCondition Then Return ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) Local $pSave, $oSave $oSaveAsWin.FindFirst( $TreeScope_Descendants, $pCondition, $pSave ) $oSave = ObjCreateInterface( $pSave, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oSave ) Then Return ConsoleWrite( "$oSave ERR" & @CRLF ) ConsoleWrite( "$oSave OK" & @CRLF ) $oSave.GetCurrentPattern( $UIA_InvokePatternId, $pInvoke ) $oInvoke = ObjCreateInterface( $pInvoke, $sIID_IUIAutomationInvokePattern, $dtagIUIAutomationInvokePattern ) If Not IsObj( $oInvoke ) Then Return ConsoleWrite( "$oInvoke ERR" & @CRLF ) ConsoleWrite( "$oInvoke OK" & @CRLF ) $oInvoke.Invoke() EndFunc SciTE output: $oUIAutomation OK $oDesktop OK --- Notepad window --- $pCondition OK $oNotepad OK --- Fill Edit element --- $pCondition OK $oEdit OK $oValue OK --- Open File menu --- $pCondition1 OK $pCondition2 OK $pCondition OK $oFile OK $oInvoke OK --- Click "Save As..." menu --- $pCondition2 OK $pCondition OK $oSaveAs OK $oInvoke OK --- Save As window --- $pCondition OK $oSaveAsWin OK --- Set File name --- $pCondition OK $oEdit OK $oValue OK --- Click Save button --- $pCondition1 OK $pCondition2 OK $pCondition OK $oSave OK $oInvoke OK Maybe somebody can show how to implement such a Notepad automation with the functions in UIAWrappers.au3 and with classic code. Summary The two most important objects in UI Automation code are the $oUIAutomation and $oUIElement objects created from IUIAutomation and IUIAutomationElement interfaces. An UI Automation element object that represents a window or control is always created with the IUIAutomationElement interface through a pointer to the element object: $oDesktop = ObjCreateInterface( $pDesktop, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) $oNotepad = ObjCreateInterface( $pNotepad, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) $oEdit = ObjCreateInterface( $pEdit, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) An UI Automation task is almost always done in two or three steps: 1. Create condition to find element 2. Find the UI Automation element 3. Extract info or perform action Each of these steps can usually be done in 1 - 3 lines of UI Automation code. All three steps can usually be done in less that 10 lines of UI Automation code (common AutoIt debug/info code not included). UI Automation actions (patterns) are performed through pattern interfaces, objects and methods. The code is nearly always implemented this way: Fill an Edit control: Local $pValue, $oValue $oEdit.GetCurrentPattern( $UIA_ValuePatternId, $pValue ) $oValue = ObjCreateInterface( $pValue, $sIID_IUIAutomationValuePattern, $dtagIUIAutomationValuePattern ) If Not IsObj( $oValue ) Then Return ConsoleWrite( "$oValue ERR" & @CRLF ) ConsoleWrite( "$oValue OK" & @CRLF ) $oValue.SetValue( "HelloWorld" ) $oEdit is an Edit control. The $oValue object represents the ValuePattern interface for the Edit control. $oValue.SetValue() sets the text in the Edit control. Click a menu item: Local $pInvoke, $oInvoke $oFile.GetCurrentPattern( $UIA_InvokePatternId, $pInvoke ) $oInvoke = ObjCreateInterface( $pInvoke, $sIID_IUIAutomationInvokePattern, $dtagIUIAutomationInvokePattern ) If Not IsObj( $oInvoke ) Then Return ConsoleWrite( "$oInvoke ERR" & @CRLF ) ConsoleWrite( "$oInvoke OK" & @CRLF ) $oInvoke.Invoke() Sleep( 100 ) $oFile is a File menu. The $oInvoke object represents the InvokePattern interface for the File menu. $oInvoke.Invoke() clicks the File menu. Sleep( 100 ) gives the File menu time to open. Click a button control: $oSave.GetCurrentPattern( $UIA_InvokePatternId, $pInvoke ) $oInvoke = ObjCreateInterface( $pInvoke, $sIID_IUIAutomationInvokePattern, $dtagIUIAutomationInvokePattern ) If Not IsObj( $oInvoke ) Then Return ConsoleWrite( "$oInvoke ERR" & @CRLF ) ConsoleWrite( "$oInvoke OK" & @CRLF ) $oInvoke.Invoke() $oSave is a Save button. The $oInvoke object represents the InvokePattern interface for the Save button. $oInvoke.Invoke() clicks the Save button. When writing UI Automation code, it's easiest to write the code in small steps and test the code after each step. Error management based on checking objects with IsObj() and ConsoleWrite() is required and sufficient. It's very rare necessary to use an actual object (COM) error handler. Too small Sleep times after a menu, dialog or window is opened is a common error.1 point
-
GUI minimum size
pixelsearch reacted to Melba23 for a topic
Anepopane, Yes, and here is how you set a min and max size: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $GUIMINWID = 300, $GUIMINHT = 100 ; set your restrictions here Global $GUIMAXWID = 800, $GUIMAXHT = 500 GUIRegisterMsg($WM_GETMINMAXINFO, "WM_GETMINMAXINFO") $hGUI = GUICreate("Test", 500, 500, -1, -1, BitOR($GUI_SS_DEFAULT_GUI, $WS_MAXIMIZEBOX, $WS_SIZEBOX)) GUISetState() $aPos = WinGetPos($hGUI) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func WM_GETMINMAXINFO($hwnd, $Msg, $wParam, $lParam) $tagMaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam) DllStructSetData($tagMaxinfo, 7, $GUIMINWID) ; min X DllStructSetData($tagMaxinfo, 8, $GUIMINHT) ; min Y DllStructSetData($tagMaxinfo, 9, $GUIMAXWID ); max X DllStructSetData($tagMaxinfo, 10, $GUIMAXHT ) ; max Y Return 0 EndFunc ;==>WM_GETMINMAXINFO Please ask if anything is unclear. M23 P.S. I move this thread into the correct forum section.1 point -
GUI minimum size (no max)
pixelsearch reacted to Xenobiologist for a topic
Hi, ??? Func WM_GETMINMAXINFO($hWnd, $MsgID, $wParam, $lParam) #forceref $MsgID, $wParam If $hWnd = $window Then; the main GUI-limited Local $size = WinGetPos($window); Local $minmaxinfo = DllStructCreate("int;int;int;int;int;int;int;int;int;int", $lParam) DllStructSetData($minmaxinfo, 7, 515); min width DllStructSetData($minmaxinfo, 8, 400); min height Return 0 Else Return 0 EndIf EndFunc So long, Mega1 point