Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/12/2019 in all areas

  1. This is what I use for launching Powershell scripts $sPowerShell = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell", "Path") $sArguments = @TempDir & "\EWS\SendMail.ps1" $iPIDps = Run($sPowerShell & ' -ExecutionPolicy ByPass -File "' & $sArguments & '"', "", @SW_HIDE, 2) If @error Then ConsoleWrite("Error encountered on Run" & @CRLF) ProcessWaitClose($iPIDps) $sOutRead = StdoutRead($iPIDps) Consolewrite("Results = " & $sOutRead & @CRLF)
    2 points
  2. ConsoleWrite("Hard crash in 3 seconds" & @LF) Sleep(3000) Local $a[9000000][2] How to benefit of a known bug!
    2 points
  3. pixelsearch

    CSV file editor

    Hi everybody The script below (901f) allows to wander easily through a listview, selecting any item or subitem by using the 4 direction keys. The Enter key is also managed and allows to fire an event (as double-click does) With the help of mikell (many thanks !) and after several tests based on 1000 rows & 6 columns, we succeeded to code a clear WM_NOTIFY function, which is simple (though solid) and should be reusable without any modification in other scripts dealing with basic listviews (we didn't use or check any particular style for the listview) Trapping the Enter key has been done by using a dummy control + Accelerators, though we spent the whole last week trapping it in another way, using Yashied's Wsp.dll (without any problem) . Finally we choosed the dummy control option... to have a smaller code. Version 901f (Nov 11, 2019) : the pic below shows how the selected subitem appears, with its specific background colour (light blue) Version 901f code : #include <GUIConstantsEx.au3> #include <GuiListView.au3> #include <WindowsConstants.au3> #include <WinAPIvkeysConstants.au3> Global $hGUI = GUICreate("Wandering through ListView (901f)", 460, 500) Global $idListView = GUICtrlCreateListView _ (" Col 0 | Col 1| Col 2| Col 3", 15, 60, 430, 400) Global $hListView = GuiCtrlGetHandle($idListView) For $iRow = 0 To 99 $sRow = StringFormat("%2s", $iRow) GUICtrlCreateListViewItem( _ "Row " & $sRow & " / Col 0 |" & _ "Row " & $sRow & " / Col 1 |" & _ "Row " & $sRow & " / Col 2 |" & _ "Row " & $sRow & " / Col 3", $idListView) Next Global $g_iColumnCount = _GUICtrlListView_GetColumnCount($idListView) -1 Global $g_iItem = -1, $g_iSubItem = -1 ; item/subitem selected in ListView control Global $idDummy_Dbl_Click = GUICtrlCreateDummy() Global $idDummy_Enter = GUICtrlCreateDummy() Global $aAccelKeys[1][2] = [["{ENTER}", $idDummy_Enter]] GUISetAccelerators($aAccelKeys) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete($hGUI) Exit Case $idDummy_Dbl_Click MsgBox($MB_TOPMOST, "Double-click activated cell", _ "Row " & $g_iItem & " / Col " & $g_iSubItem) Case $idDummy_Enter If _WinAPI_GetFocus() = $hListView And $g_iItem > -1 Then MsgBox($MB_TOPMOST, "Enter activated cell", _ "Row " & $g_iItem & " / Col " & $g_iSubItem) EndIf EndSwitch WEnd ;============================================ Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $tNMHDR, $hWndFrom, $iIDFrom, $iCode $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = DllStructGetData($tNMHDR, "hWndFrom") $iCode = DllStructGetData($tNMHDR, "Code") Static $bMouseDown = False, $bNotXP = Not (@OSVersion = "WIN_XP") Switch $hWndFrom Case $hListView Switch $iCode Case $NM_CUSTOMDRAW Local $tCustDraw = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) Local $iDrawStage = DllStructGetData($tCustDraw, "dwDrawStage") If $iDrawStage = $CDDS_PREPAINT Then Return $CDRF_NOTIFYITEMDRAW If $iDrawStage = $CDDS_ITEMPREPAINT Then Return $CDRF_NOTIFYSUBITEMDRAW Local $iItem = DllStructGetData($tCustDraw, "dwItemSpec") Local $iSubItem = DllStructGetData($tCustDraw, "iSubItem") Local $iColor = 0xFF000000 ; this is $CLR_DEFAULT in ColorConstants.au3 If $iItem = $g_iItem And $iSubItem = $g_iSubItem Then $iColor = 0xFFFFC0 ; light blue for 1 subitem (BGR) EndIf DllStructSetData($tCustDraw, "clrTextBk", $iColor) Return $CDRF_NEWFONT Case $LVN_KEYDOWN If $bMouseDown Or $g_iItem = -1 Then Return 1 ; don't process Local $tInfo = DllStructCreate($tagNMLVKEYDOWN, $lParam) Local $iVK = DllStructGetData($tInfo, "VKey") Switch $iVK Case $VK_RIGHT If $g_iSubItem < $g_iColumnCount Then $g_iSubItem += 1 If $bNotXP Then _GUICtrlListView_RedrawItems($hListview, $g_iItem, $g_iItem) EndIf Case $VK_LEFT If $g_iSubItem > 0 Then $g_iSubItem -= 1 If $bNotXP Then _GUICtrlListView_RedrawItems($hListview, $g_iItem, $g_iItem) EndIf Case $VK_SPACE ; spacebar would select the whole row Return 1 EndSwitch Case $NM_RELEASEDCAPTURE $bMouseDown = True Local $iItemSave = $g_iItem Local $aHit = _GUICtrlListView_SubItemHitTest($hListView) $g_iItem = $aHit[0] $g_iSubItem = $aHit[1] If $g_iItem = -1 And $iItemSave > -1 Then _GUICtrlListView_RedrawItems($hListview, $iItemSave, $iItemSave) EndIf Case $LVN_ITEMCHANGED Local $tInfo = DllStructCreate($tagNMLISTVIEW, $lParam) Local $iNewState = DllStructGetData($tInfo, "NewState") Switch $iNewState Case BitOr($LVIS_FOCUSED, $LVIS_SELECTED) $g_iItem = DllStructGetData($tInfo, "Item") _GUICtrlListView_SetItemSelected($hListview, $g_iItem, False) EndSwitch Case $NM_CLICK, $NM_RCLICK $bMouseDown = False Case $NM_DBLCLK $bMouseDown = False If $g_iItem > -1 Then GUICtrlSendToDummy($idDummy_Dbl_Click) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Version 901k (Dec 16, 2019) What started with a simple "wander through listview" has turned now to a functional CSV file editor, which can be useful to modify your CSV files with AutoIt : Here are the instructions to use the script, based on a CSV file starting like this : street,city,zip,state,beds,baths,sq__ft,type,sale_date,price,latitude,longitude 3526 HIGH ST,SACRAMENTO,95838,CA,2,1,836,Residential,Wed May 21 00:00:00 EDT 2008,59222,38.631913,-121.434879 51 OMAHA CT,SACRAMENTO,95823,CA,3,1,1167,Residential,Wed May 21 00:00:00 EDT 2008,68212,38.478902,-121.431028 ... 1) Import options : comma delimited (default) No need to change anything if your CSV is comma delimited (other options are Semicolon delimited, Tab delimited) 2) Import options : First row = headers (default = checked) * Keep it checked if the 1st row of your imported file contains headers (that's the case in our example) * UNcheck it if the 1st row contains data, making listview headers appear like this : Col 0 | Col 1 | Col 2 ... 3) Import your CSV file : Only now the listview will be created dynamically. As soon as it is populated, GUI becomes resizable/maximizable, which can be helpful during modifications of a listview containing many columns. 4) Selection color : light blue (default) You can change the selected cell background color by clicking the "Selection color" button : this will open Windows color picker. 5) Editing a listview cell : done by Enter key (or double-click), this is how the edited cell will appear : * Please note that the edited background color (green in the pic) depends on each computer theme. It is not related to the selected background we discussed in 4) * Validate your modification with Enter key, or cancel the modification (revert) with Escape Key 6) Edit Font size : 15 (default) 15 was good in the precedent pic, the edited cell had its content "RIO LINDA" perfectly aligned with all other cells (on my computer). Here again, the font height required depends on each computer : if you want the edited font to be bigger (or smaller), just use the updown control. 7) Chained Edit ? (default = No) * "No" => when you finish editing a cell (Enter key), the same cell stays selected. * "Horizontally" => If checked, edition will automatically continue with the cell on its right. * "Vertically" => If checked, edition will automatically continue with the cell below. This feature can be very useful when you modify cells of a whole colum (vertically) or cells by row (horizontally) 8 ) Inserting a blank line (not in Gui) : press the "Ins" key : 9) Deleting a line (not in Gui) : press the "Del" key : 10) Export CSV file : Filename automatically suggested for export will be : Filename import & actual date & actual time, for example : Import name = "Sales Results.csv" => suggested Export name = "Sales Results_2019-12-16 16:00:59.csv" Version 901m (Dec 18, 2019) Yesterday, mikell suggested to import the csv file by dropping it directly into the GUI, good idea This new version 901m allows it. Now there are 2 ways to import the csv file : * Import button * Drag and drop into the large droppable zone, as shown in the pic below (this zone will be reused to create the listview at same coords) Version 901n (Dec 20, 2019) As t0nZ got tons of csv files, pipe "|" separated, here is a new version allowing this 4th separator Version 901p (Dec 25, 2019) New functionality : now you can drag headers to reorder columns. It may help some users who need it while editing their file. Exported CSV file will be saved according to the new columns order. Version 901r (Dec 29, 2019) New functionality : Numeric sort on any column (right click on column header) It is recommended to backup (export) your file before sorting, just in case you need a copy of it, unsorted. Version 901s (Dec 30, 2019) 1 functionality added : String sort (right click on column header) Numeric sort is alright in most cases, but sometimes we also need a String sort like shown in the following picture. Both ways of sorting (numeric and string) are found in this new release. Version 901t (Jan 3, 2020) 3 functionalities added Rename Header , Insert Column , Delete Column (right click on column header to display its context menu) Version 901u (Jan 6, 2020) 1 functionality added : Natural sort. Thanks to jchd for the idea and Melba23 for his function ArrayMultiColSort() included in the script. Though this natural sort isn't fully implemented, it should work when numbers precede letters (see pic below or better, try it on the "street" column found in the downloadable csv test file below) Natural sort duration + listview update are fast, maybe because of the new function _BufferCreate() described here and now added to the script. Version 901w (Jan 10, 2020) Two functionalities added : 1) Close File button, which allows to import other csv file(s) during the same session 2) Import speed has been improved because the listview control is now populated directly by an Array and not anymore by GUICtrlCreateListViewItem() This explains why, in this version, there are no more Control id's for listview items, allowing to empty the listview content in a snap with this line of code : _SendMessage($g_hListView, $LVM_DELETEALLITEMS) That's what it took to add the Close File button and import several csv files during the same session, avoiding id leaks. Please report if any issue is encountered. Version 901x (Jan 14, 2020) One minor functionality added : number of rows is now displayed just under the listview, it may be handy sometimes. Other minor changes included (natural sort speed improved) Credits : Many thanks to Czardas for his function _CSVSplit() and guinness for his function _SaveCSV(), guys you did a great job. Thanks to Musashi : your suggestions and time passed on testing beta versions of the script, that was really helpful and challenging. Not sure I would have ended this script without your detailed reports. Mikell : the 1st step above (901f) that we wrote together, it all started from here. Your knowledge and kindness are legendary ! Not forgetting all other persons who were inspiring : LarsJ, Melba23, jpm, that list could be endless... Download link : version 901x - Jan 14, 2020 (minor update on Jan 15) 901x - CSV file editor.au3 Test csv file (986 rows/12cols) : Sacramento real estate transactions.csv
    1 point
  4. The newer version of Windows 10 come with, in every release, better "Dark mode" but, it never gets quite done. So, I'm using the High Contrast theme but, the color selection interface leave much to be desired. Hence this "Fine tuner" for the theme: ( mouse over, will show a tip of what a column of controls are for ) Next in line is to have a preview but I'll need some help ( requested here ), to get it done. Solved Is functional as is. If you change a color with the windows interface, you can later fine tune it with this. Edit1: Changed the criteria: Is now a "MyFineTuned.theme". The other trend of thought had basic problems. This is a better approach. Edit2: still incomplete but more functional. Still looking for a way to get the title colors for Win32 GUI right Done. The files are now in the downloads section .
    1 point
  5. Musashi

    CSV file editor

    Just an info : Currently I am sitting on my old notebook (Win7, AutoIt 3.3.14.0). When I run the script, the Up, Down and Enter keys are working as expected, but Left and Right keys do not. However, I strongly suspect that this has nothing to do with your great script, but is rather due to my laziness to update the notebook to AutoIt 3.3.14.5. EDIT : Thanks to @mikell as well !
    1 point
  6. The Run command supports and optional show_flag parameter. Try setting it to @SW_Hide.
    1 point
  7. Very handy tool. A BIG THANK YOU. ps. When you release next version please upload them here: https://www.autoitscript.com/forum/files/category/20-windows/
    1 point
  8. Tested with your code and your ico and it works perfect Win7 and Win10 !
    1 point
  9. You need to add the resources like in my example, compile the script and run the EXE. Just change path, ico name, it will work. Use my example first, so you know it is working then modify yours...
    1 point
  10. Jos

    AutoIT Editor Dark Theme

    I looked at your files, but there are too many differences for a simple match so needs work. Also no idea which one you used for your "light" version you posted. @jpm worked on the current dark version so maybe he can have a look to see what we like to copy into the current version? Jos
    1 point
  11. See : https://www.autoitscript.com/autoit3/docs/functions/FileInstall.htm Edit : or a solution from the grandmaster @UEZ himself : https://www.autoitscript.com/forum/topic/134350-file-to-base64-string-code-generator-v120-build-2015-01-20-embed-your-files-easily/
    1 point
  12. Nine

    Processor Usage

    Like previously, just put a small Sleep (100) inside the loop. While we are there, you do not need to put () around a If. It is not necessary. Also == is for comparing case sensitive strings, not numbers. Use = instead. So your code should look like this : #NoTrayIcon #include <MsgBoxConstants.au3> #include <TrayConstants.au3> #include <Misc.au3> _Singleton(@ScriptName, 0) HotKeySet("{ESC}", "On_Exit") $lastPos = MouseGetPos() $lastMove = TimerInit() Opt("TrayMenuMode", 3) _ST() Func _ST() Flash() TraySetState($TRAY_ICONSTATE_SHOW) While 1 Sleep (100) $curPos = MouseGetPos() If $lastPos[0] = $curPos[0] And $lastPos[1] = $curPos[1] Then If TimerDiff($lastMove) > 250000 Then MouseMove(Random(1, @DesktopWidth, 1), Random(1, @DesktopHeight, 1)) Else $lastPos = $curPos $lastMove = TimerInit() EndIf WEnd EndFunc Func Flash() TraySetState($TRAY_ICONSTATE_FLASH) Sleep(1000) EndFunc Func On_Exit() Exit EndFunc
    1 point
  13. pixelsearch

    Processor Usage

    Hi mucitbey The solution is to move the 2nd Sleep(10) between Do and Until, which will reduce drastically the CPU usage : #NoTrayIcon #Include <Timers.au3> HotKeySet("{ESC}", "On_Exit") While 1 If _Timer_GetIdleTime() > 6300000 Then Run("Closer.exe") While _Timer_GetIdleTime() > 500 Sleep(10) WEnd ProcessClose("Closer.exe") EndIf ; Sleep(10) $timer = TimerInit() Do Sleep(10) ; <======= Until TimerDiff($timer) >= 600000 $iFileExist = FileExists("\\ANKSERVER\ank\Tools\csb.ini") If $iFileExist Then Run("C:\RedStone\Tools\Message.exe") EndIf WEnd Func On_Exit() Exit EndFunc
    1 point
  14. Look here at my very old the same problem and solution (read whole topic) --> AutoIt3Help.exe was the problem: Side note: You can install more AutoIt's versions on one machine and use different version for different scripts. Here is description how I do it and use it:
    1 point
  15. 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
  16. Normal Windows network path has the format like \\DOMAIN\Application\Folder\Filename.xls But you want to use something like http://... you should use FTP* or TCP* or InetGet to copy files.
    1 point
  17. Hi, I had the problem that the original UDF with me could not open files of the format * .accdb (2007-2016). The problem could be solved by adjusting the ADO.au3 file. From: Func _ADO_ConnectionString_Access($sFileFullPath, $sUser = Default, $sPassword = Default, $sDriver = Default) If $sUser = Default Then $sUser = '' Else $sUser = 'Uid=' & $sUser & ';' EndIf If $sPassword = Default Then $sPassword = '' Else $sPassword = 'PWD=' & $sPassword & ';' EndIf If $sDriver = Default Then If StringRight($sFileFullPath, 6) = '.accdb' Then $sDriver = 'Microsoft Access Driver (*.mdb, *.accdb)' Else $sDriver = 'Microsoft Access Driver (*.mdb)' EndIf EndIf Local $sConnectionString = 'Driver={' & $sDriver & '};Dbq="' & $sFileFullPath & '";' & $sUser & $sPassword If Not StringRegExp($sConnectionString, '(?i)(Microsoft Access Driver \(*.mdb\)|Microsoft Access Driver \(*.mdb, *.accdb\))', $STR_REGEXPMATCH) Then $sConnectionString = StringReplace($sConnectionString, ';Dbq=', ' ;Data Source=') EndIf Return SetError($ADO_ERR_SUCCESS, $ADO_EXT_DEFAULT, $sConnectionString) EndFunc ;==>_ADO_ConnectionString_Access To: Func _ADO_ConnectionString_Access($sFileFullPath, $sUser = Default, $sPassword = Default, $sDriver = Default) If $sUser = Default Then $sUser = '' Else $sUser = 'Uid=' & $sUser & ';' EndIf If $sPassword = Default Then $sPassword = '' Else $sPassword = 'PWD=' & $sPassword & ';' EndIf If $sDriver = Default Then If StringRight($sFileFullPath, 6) = '.accdb' Then $sDriver = 'Microsoft.ACE.OLEDB.12.0' Else $sDriver = 'Microsoft Access Driver (*.mdb)' EndIf EndIf Local $sConnectionString = 'Provider=' & $sDriver & ';Dbq="' & $sFileFullPath & '";' & $sUser & $sPassword If Not StringRegExp($sConnectionString, '(?i)(Microsoft Access Driver \(*.mdb\)|Microsoft Access Driver \(*.mdb, *.accdb\))', $STR_REGEXPMATCH) Then $sConnectionString = StringReplace($sConnectionString, ';Dbq=', ' ;Data Source=') EndIf Return SetError($ADO_ERR_SUCCESS, $ADO_EXT_DEFAULT, $sConnectionString) EndFunc ;==>_ADO_ConnectionString_Access
    1 point
  18. R0G

    Digital Sign Tool

    Digital Sign Tool V1.6 Features: Digitally sign: (.exe) (.cab) (.cat) (.ocx) (.dll) (.stl) Metro style GUI thanks @BBs19 Error logging Multi file support Instructions: You must have your (.pfx) certificate imported to the "Current User\Personal\Certificates" store Your certificate must be exportable Select your digital certificate from the drop down menu Click browse to add your files to sign Click sign For more information please visit: https://www.autoitscript.com/forum/topic/149137-sign-your-exe-with-a-digital-signature-signtoolexe/#comment-1061738 https://msdn.microsoft.com/en-us/library/bfsktky3(vs.100).aspx?f=255&MSPPError=-2147217396 Changelog: V1.6 1/8/2021 - Updated broken Signing URL - Added option to change signing URL in settings - Other Bug Fixes Download: Digital Sign Tool V1.6.zip Digital Sign Tool V0.5.zip
    1 point
  19. And you felt the need to resurrect it after 2 years in a 10 year old thread?
    1 point
  20. UEZ

    GDI+ Image in a Tab Control

    I would do it rather this way: #include <GUIConstantsEx.au3> #include <GDIPlus.au3> Opt("GUIOnEventMode", 1) Global $NavigationBar _CreateGui() Func _CreateGUI() _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\FF.png") ;<-- your image $iWidth = _GDIPlus_ImageGetWidth($hImage) $iHeight = _GDIPlus_ImageGetHeight($hImage) $hGDIBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) _GDIPlus_ImageDispose($hImage) $MainGUI = GuiCreate("Test GUI", 1000, 500) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") $NavigationBar = GuiCtrlCreateTab(20, 10, 960, 480) GUICtrlSetOnEvent(-1, "_NavigationCheck") $GlossaryTab = GuiCtrlCreateTabItem("Glossary") $iPic = GUICtrlCreatePic("", 80, 200, $iWidth, $iHeight) $Item1Tab = GuiCtrlCreateTabItem("Tab 2") GuiCtrlCreateLabel("Test", 200, 200) _WinAPI_DeleteObject(GUICtrlSendMsg($iPic, 0x0172, $IMAGE_BITMAP, $hGDIBitmap)) ;$STM_SETIMAGE = 0x0172 _WinAPI_DeleteObject($hGDIBitmap) _GDIPlus_Shutdown() GuiSetState() EndFunc Func _NavigationCheck() $ReadNavigationBar = GUiCtrlRead($NavigationBar) ; Do other stuff if need be later EndFunc Func _Exit() Exit EndFunc While 1 Sleep(10) WEnd Otherwise image will be erased when switching the tabs, GUI is minimized/restored again or GUI will be moved partial outside the screen borders.
    1 point
×
×
  • Create New...