Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/01/2020 in all areas

  1. Trong

    ImageSearchUDF

    Version v3.3.3

    11,559 downloads

    ImageSearch UDF - AutoIt Wrapper for ImageSearchDLL Overview ImageSearchDLL_UDF.au3 is a high-level AutoIt wrapper for ImageSearchDLL, providing easy-to-use functions for image searching, mouse automation, and multi-monitor support. It handles all the complexity of DLL calls and provides a clean, reliable API with built-in error handling and fallback mechanisms. Author: Dao Van Trong - TRONG.PRO UDF Version: v3.3 Compatible with: ImageSearchDLL v3.3+ AutoIt Version: 3.3.16.1+ License: MIT License ☕ Support My Work Enjoy my work? Buy me a 🍻 or tip via ❤️ PayPal Your support helps me continue developing and maintaining this library for the community! 🙏 Key Features Search Functions Screen Search: Find images on screen with multi-monitor support Image-in-Image Search: Find images within other images HBITMAP Search: Direct bitmap handle searching Wait & Click: Wait for image and auto-click when found Cache Control: Enable/disable persistent caching per search Mouse Automation (v3.3 Enhanced) Multi-Monitor Support: 100% reliable on all monitor configurations Negative Coordinates: Full support via WinAPI SetCursorPos Click Simulation: WinAPI mouse_event for all button types Smooth Movement: Optional speed parameter for cursor animation Window Clicks: Click relative to window positions Monitor Management Auto-Detection: Enumerate all connected monitors Virtual Desktop: Coordinate conversion between monitor and virtual space Specific Monitor Search: 2-3x faster when searching single monitor Monitor Info: Get position, size, and primary status Installation Include the UDF in your AutoIt script: #include "ImageSearchDLL_UDF.au3" Place DLL in same directory as script: ImageSearchDLL_x64.dll for x64 AutoIt ImageSearchDLL_x86.dll for x86 AutoIt Not required, as the DLL is already embedded in the UDF! Initialize (automatic on first use): _ImageSearch_Startup() ; Optional - auto-called if needed Quick Start Examples Example 1: Simple Image Search #include "ImageSearchDLL_UDF.au3" ; Search for image on screen Local $aResult = _ImageSearch("button.png") If $aResult[0][0] > 0 Then ConsoleWrite("Found at: X=" & $aResult[1][0] & ", Y=" & $aResult[1][1] & @CRLF) ; Click the found image _ImageSearch_MouseClick("left", $aResult[1][0], $aResult[1][1]) Else ConsoleWrite("Image not found" & @CRLF) EndIf Example 2: Multi-Monitor Search #include "ImageSearchDLL_UDF.au3" ; Search on all monitors (virtual desktop) Local $aResult = _ImageSearch("icon.png", 0, 0, 0, 0, -1) ; OR search on specific monitor (faster!) Local $aResult = _ImageSearch("icon.png", 0, 0, 0, 0, 2) ; Monitor 2 If $aResult[0][0] > 0 Then ConsoleWrite("Found " & $aResult[0][0] & " match(es)" & @CRLF) For $i = 1 To $aResult[0][0] ConsoleWrite("Match " & $i & ": X=" & $aResult[$i][0] & ", Y=" & $aResult[$i][1] & @CRLF) Next EndIf Example 3: Wait and Click #include "ImageSearchDLL_UDF.au3" ; Wait up to 5 seconds for image, then click it Local $iResult = _ImageSearch_WaitClick(5000, "submit.png", "left", 1) If $iResult Then ConsoleWrite("Image found and clicked!" & @CRLF) Else ConsoleWrite("Timeout - image not found" & @CRLF) EndIf Example 4: Find All Occurrences #include "ImageSearchDLL_UDF.au3" ; Find all matches (up to 10) Local $aResult = _ImageSearch("item.png", 0, 0, 0, 0, -1, 10, 10) If $aResult[0][0] > 0 Then For $i = 1 To $aResult[0][0] ConsoleWrite("Match " & $i & ": ") ConsoleWrite("X=" & $aResult[$i][0] & ", Y=" & $aResult[$i][1]) ConsoleWrite(", W=" & $aResult[$i][2] & ", H=" & $aResult[$i][3] & @CRLF) Next EndIf Example 5: Image-in-Image Search #include "ImageSearchDLL_UDF.au3" ; Search for button.png within screenshot.png Local $aResult = _ImageSearch_InImage("screenshot.png", "button.png", 15, 5) If $aResult[0][0] > 0 Then ConsoleWrite("Found " & $aResult[0][0] & " match(es) in image" & @CRLF) EndIf Example 6: Region Search with Tolerance #include "ImageSearchDLL_UDF.au3" ; Search in specific region with high tolerance Local $aResult = _ImageSearch("target.png", 100, 100, 800, 600, -1, 20) If $aResult[0][0] > 0 Then ConsoleWrite("Found at: " & $aResult[1][0] & ", " & $aResult[1][1] & @CRLF) EndIf Example 7: Cache-Enabled Search #include "ImageSearchDLL_UDF.au3" ; Enable cache for 30-50% performance boost on repeated searches Local $aResult = _ImageSearch("icon.png", 0, 0, 0, 0, -1, 10, 1, 1, 1.0, 1.0, 0.1, 0, 1) ; ↑ ; iUseCache=1 If $aResult[0][0] > 0 Then ConsoleWrite("Found (cached search): " & $aResult[1][0] & ", " & $aResult[1][1] & @CRLF) EndIf Example 8: Monitor Management #include "ImageSearchDLL_UDF.au3" ; Get monitor information _ImageSearch_Monitor_GetList() ConsoleWrite("Total monitors: " & $g_aMonitorList[0][0] & @CRLF) For $i = 1 To $g_aMonitorList[0][0] ConsoleWrite("Monitor " & $i & ": " & _ $g_aMonitorList[$i][5] & "x" & $g_aMonitorList[$i][6] & _ ($g_aMonitorList[$i][7] ? " (Primary)" : "") & @CRLF) Next ; Convert coordinates between monitor and virtual desktop Local $aVirtual = _ImageSearch_Monitor_ToVirtual(2, 100, 200) ConsoleWrite("Monitor 2 (100,200) = Virtual (" & $aVirtual[0] & "," & $aVirtual[1] & ")" & @CRLF) Core Functions Reference Search Functions _ImageSearch() _ImageSearch($sImagePath, [$iLeft=0], [$iTop=0], [$iRight=0], [$iBottom=0], [$iScreen=-1], [$iTolerance=10], [$iResults=1], [$iCenterPOS=1], [$fMinScale=1.0], [$fMaxScale=1.0], [$fScaleStep=0.1], [$iReturnDebug=0], [$iUseCache=0]) Parameters: $sImagePath - Image file path (or multiple: "img1.png|img2.png") $iLeft, $iTop, $iRight, $iBottom - Search region (0 = full screen) $iScreen - Monitor: -1=all, 0=primary, 1=first, 2=second, etc. $iTolerance - Color tolerance 0-255 $iResults - Max results to return (1-64) $iCenterPOS - 1=return center, 0=return top-left $fMinScale, $fMaxScale, $fScaleStep - Scaling parameters $iReturnDebug - 1=enable debug output $iUseCache - 1=enable cache, 0=disable Returns: Array[0][0] = match count Array[1..n][0] = X coordinate Array[1..n][1] = Y coordinate Array[1..n][2] = Width Array[1..n][3] = Height _ImageSearch_InImage() _ImageSearch_InImage($sSourceImage, $sTargetImage, [$iTolerance=10], [$iResults=1], [$iCenterPOS=1], [$fMinScale=1.0], [$fMaxScale=1.0], [$fScaleStep=0.1], [$iReturnDebug=0], [$iUseCache=0]) Search for target image(s) within a source image file. _ImageSearch_Wait() _ImageSearch_Wait($iTimeout, $sImagePath, [$iLeft=0], [$iTop=0], [$iRight=0], [$iBottom=0], [$iScreen=-1], [$iTolerance=10], [$iResults=1], [$iCenterPOS=1], [$fMinScale=1.0], [$fMaxScale=1.0], [$fScaleStep=0.1], [$iReturnDebug=0], [$iUseCache=0]) Wait for image to appear (with timeout in milliseconds). _ImageSearch_WaitClick() _ImageSearch_WaitClick($iTimeout, $sImagePath, [$sButton="left"], [$iClicks=1], [$iLeft=0], [$iTop=0], [$iRight=0], [$iBottom=0], [$iScreen=-1], [$iTolerance=10], [$iResults=1], [$iCenterPOS=1], [$fMinScale=1.0], [$fMaxScale=1.0], [$fScaleStep=0.1], [$iReturnDebug=0], [$iUseCache=0]) Wait for image and automatically click it when found. Mouse Functions (v3.3 Enhanced) _ImageSearch_MouseMove() _ImageSearch_MouseMove($iX, $iY, [$iSpeed=0], [$iScreen=-1]) Move mouse cursor to coordinates. Supports negative coordinates for multi-monitor. Uses WinAPI SetCursorPos for 100% reliability $iSpeed - 0=instant, >0=smooth movement with steps _ImageSearch_MouseClick() _ImageSearch_MouseClick([$sButton="left"], [$iX=-1], [$iY=-1], [$iClicks=1], [$iSpeed=0], [$iScreen=-1]) Click mouse at coordinates. Supports negative coordinates for multi-monitor. Uses WinAPI mouse_event for reliable clicking $sButton - "left", "right", "middle" $iX, $iY - Virtual desktop coordinates (-1 = current position) _ImageSearch_MouseClickWin() _ImageSearch_MouseClickWin($sTitle, $sText, $iX, $iY, [$sButton="left"], [$iClicks=1], [$iSpeed=0]) Click at window-relative coordinates. Monitor Functions _ImageSearch_Monitor_GetList() _ImageSearch_Monitor_GetList() Enumerate all monitors and populate $g_aMonitorList array. Global Array Structure: $g_aMonitorList[0][0] = Total monitor count $g_aMonitorList[i][0] = Handle $g_aMonitorList[i][1] = Left $g_aMonitorList[i][2] = Top $g_aMonitorList[i][3] = Right $g_aMonitorList[i][4] = Bottom $g_aMonitorList[i][5] = Width $g_aMonitorList[i][6] = Height $g_aMonitorList[i][7] = IsPrimary (1/0) $g_aMonitorList[i][8] = Device name _ImageSearch_Monitor_ToVirtual() _ImageSearch_Monitor_ToVirtual($iMonitor, $iX, $iY) Convert monitor-relative coordinates to virtual desktop coordinates. _ImageSearch_Monitor_FromVirtual() _ImageSearch_Monitor_FromVirtual($iMonitor, $iX, $iY) Convert virtual desktop coordinates to monitor-relative coordinates. Utility Functions _ImageSearch_CaptureScreen() _ImageSearch_CaptureScreen([$iLeft=0], [$iTop=0], [$iRight=0], [$iBottom=0], [$iScreen=-1]) Capture screen region as HBITMAP handle. _ImageSearch_hBitmapLoad() _ImageSearch_hBitmapLoad($sImageFile, [$iAlpha=0], [$iRed=0], [$iGreen=0], [$iBlue=0]) Load image file as HBITMAP with optional background color. _ImageSearch_GetVersion() _ImageSearch_GetVersion() Get DLL version string. _ImageSearch_GetSysInfo() _ImageSearch_GetSysInfo() Get system info (CPU, screen, cache stats). _ImageSearch_ClearCache() _ImageSearch_ClearCache() Clear all DLL caches (location and bitmap). Performance Tips Cache System Enable caching for repeated searches: $iUseCache=1 30-50% faster on subsequent searches Persistent across script runs Auto-validated (removes stale entries) Multi-Monitor Optimization Use specific monitor ($iScreen=1 or 2) for 2-3x faster search Use virtual desktop ($iScreen=-1) only when needed Coordinates are always in virtual desktop space (may be negative) Search Optimization Smaller region = faster search Higher tolerance = faster but less accurate Fewer results ($iResults=1) = faster Disable debug in production ($iReturnDebug=0) Version 3.3 Improvements Fixed Issues ✅ Multi-Monitor Mouse Movement - Now 100% reliable using WinAPI ✅ Negative Coordinates - Full support for monitors positioned left/above primary ✅ Mouse Click Reliability - WinAPI mouse_event never fails ✅ Coordinate Conversion - Proper handling of virtual desktop space Enhanced Features Debug logging shows actual mouse position after move Better error handling with meaningful error codes All mouse functions bypass DLL for maximum reliability Smooth cursor movement with customizable speed Breaking Changes Mouse functions no longer rely on DLL implementation Always use WinAPI for mouse operations (more reliable) Troubleshooting "DLL not found" Error Ensure DLL is in same directory as script Use correct architecture (x64 vs x86) Check with FileExists($g_sImgSearchDLL_Path) Mouse Not Moving on Second Monitor ✅ Fixed in v3.3! Now uses WinAPI SetCursorPos Coordinates are virtual desktop (may be negative) Update to UDF v3.3 or later Image Not Found Check image file exists Increase tolerance ($iTolerance=20) Enable debug ($iReturnDebug=1) to see search info Try different region/monitor settings Slow Search Performance Enable cache ($iUseCache=1) Use specific monitor instead of all monitors Reduce search region Lower max results Example: Complete Script #include "ImageSearchDLL_UDF.au3" ; Initialize _ImageSearch_Startup() ; Show system info ConsoleWrite("UDF: " & $IMGS_UDF_VERSION & @CRLF) ConsoleWrite("DLL: " & _ImageSearch_GetVersion() & @CRLF) ConsoleWrite(_ImageSearch_GetSysInfo() & @CRLF) ; Search for image with cache enabled Local $aResult = _ImageSearch("target.png", 0, 0, 0, 0, -1, 10, 5, 1, 1.0, 1.0, 0.1, 1, 1) If $aResult[0][0] > 0 Then ConsoleWrite("Found " & $aResult[0][0] & " match(es):" & @CRLF) For $i = 1 To $aResult[0][0] ConsoleWrite(" Match " & $i & ": ") ConsoleWrite("X=" & $aResult[$i][0] & ", Y=" & $aResult[$i][1]) ConsoleWrite(", W=" & $aResult[$i][2] & ", H=" & $aResult[$i][3] & @CRLF) ; Move mouse and click _ImageSearch_MouseMove($aResult[$i][0], $aResult[$i][1], 10) Sleep(500) _ImageSearch_MouseClick("left", $aResult[$i][0], $aResult[$i][1]) Sleep(1000) Next Else ConsoleWrite("No matches found" & @CRLF) EndIf ; Cleanup _ImageSearch_Shutdown() License & Contact Author: Dao Van Trong Website: TRONG.PRO Email: trong@email.com License: MIT License AutoIt Forum: Post in AutoIt General Help See Also README.md - DLL API reference and C++ examples ImageSearchDLL_TestSuite.au3 - Interactive GUI test application Thank you for using ImageSearch UDF! 🚀
    1 point
  2. The loop is probably most effective and it does not "take a lot of line of code" (it probably takes less lines than my example). That aside, pulling this off without a loop sounded like fun this assumes you have read your excel file to an array that looks like the one in the OP: #include<array.au3> local $a[3][4] = [["1" , "First name" , "Last name" , "date of birth"],["2", "Mathieu" , "Laplante" , "may, 4th 1980"],["3" , "Ginette" , "Pare" , "oct, 10th, 1974"]] _ArrayTranspose($a) msgbox(0 , '' , _ArraySearch($a , "Last name")) edit: wait wth, you only need the column that appears in (or do you need need row and column like a jeopardy board)? How did you know it was in row 1 to search a1-c1?
    1 point
  3. It is because there is a ; at the end of your environment PATH ? Mine's fine...
    1 point
  4. Chrome Driver (WebDriver) is just another means to interact with a browser. So what is the need to work without a browser? At least IE comes with the OS.
    1 point
  5. LarsJ

    UI Automation Events

    Windows 8, Windows 8.1 and Windows 10 updates In Windows 8 and later, new event handlers have been added and new events and property changes have been added to existing event handlers. This is an update to be able to take advantage of these new event handlers, events and property changes. Four new event handlers have been added: IUIAutomationTextEditTextChangedEventHandler ; Windows 8.1 IUIAutomationChangesEventHandler ; Windows 10-1703 IUIAutomationNotificationEventHandler ; Windows 10-1709 IUIAutomationActiveTextPositionChangedEventHandler ; Windows 10-1809 The corresponding four new EventIds that can be used in the existing AutomationEventHandler are: Global Const $UIA_TextEdit_TextChangedEventId = 20032 ; Windows 8.1 Global Const $UIA_ChangesEventId = 20034 ; Windows 10 Global Const $UIA_NotificationEventId = 20035 ; Windows 10 Global Const $UIA_ActiveTextPositionChangedEventId = 20036 ; Windows 10 In addition to the listed EventIds, there are 10 more EventIds that can be used in the existing AutomationEventHandler. And there are more than 60 new PropertyIds that can be used in the existing PropertyChangedEventHandler. By detecting events for the four new EventIds listed above in UI Automation Event Monitor (UIAEHEvents.au3, see description of updates below) I've tried to find applications that actually generates some of these new events. I've found that the Windows 10 Calculator and Microsoft Edge browser generates Notification events. With the new NotificationEventHandler it's possible to obtain further information about these events. I've not found any applications that generates the other three events. And thus I've not found any applications where it's possible to test the new TextEditTextChangedEventHandler, ChangesEventHandler and ActiveTextPositionChangedEventHandler. Therefore, the only new event handler implemented in this update is the NotificationEventHandler. NotificationEventHandler NotificationEventHandler exposes a method to handle Microsoft UI Automation notification events. The UDF is implemented in Includes\UIAEH_NotificationEventHandler.au3: #include-once #include "UIA_Constants.au3" #include "UIA_ConstNames.au3" #include "UIA_Functions.au3" #include "ObjectFromTag.au3" NotificationKindSetNames() NotificationProcessingSetNames() Global $oUIAEH_NotificationEventHandler, $tUIAEH_NotificationEventHandler Func UIAEH_NotificationEventHandlerCreate() $oUIAEH_NotificationEventHandler = ObjectFromTag( "UIAEH_NotificationEventHandler_", $dtag_IUIAutomationNotificationEventHandler, $tUIAEH_NotificationEventHandler, True ) EndFunc Func UIAEH_NotificationEventHandlerDelete() $oUIAEH_NotificationEventHandler = 0 DeleteObjectFromTag( $tUIAEH_NotificationEventHandler ) EndFunc #cs ; Insert the two functions here in user code ; This is the function that receives events Func UIAEH_NotificationEventHandler_HandleNotificationEvent( $pSelf, $pSender, $iKind, $iProcessing, $pDisplayStr, $pActivityId ) ; Ret: long Par: ptr;long;long;ptr;ptr ConsoleWrite( @CRLF & "UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = " & $aNotificationKindNames[$iKind] & @CRLF ) ConsoleWrite( "UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = " & $aNotificationProcessingNames[$iProcessing] & @CRLF ) ConsoleWrite( "UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = " & UIA_String( $pDisplayStr ) & @CRLF ) ConsoleWrite( "UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = " & UIA_String( $pActivityId ) & @CRLF ) Local $oSender = ObjCreateInterface( $pSender, $sIID_IUIAutomationElement9, $dtag_IUIAutomationElement9 ) ; Windows 10 Last $oSender.AddRef() ConsoleWrite( "Title = " & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_NamePropertyId ) & @CRLF & _ "Class = " & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_ClassNamePropertyId ) & @CRLF & _ "Ctrl type = " & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_ControlTypePropertyId ) & @CRLF & _ "Ctrl name = " & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_LocalizedControlTypePropertyId ) & @CRLF & _ "Handle = " & "0x" & Hex( UIAEH_GetCurrentPropertyValue( $oSender, $UIA_NativeWindowHandlePropertyId ) ) & @CRLF & _ "Value = " & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_ValueValuePropertyId ) & @CRLF ) Return 0x00000000 ; $S_OK #forceref $pSelf EndFunc ; Auxiliary function (for simple properties only) ; There must be only one instance of this function Func UIAEH_GetCurrentPropertyValue( $oSender, $iPropertyId ) Local $vPropertyValue $oSender.GetCurrentPropertyValue( $iPropertyId, $vPropertyValue ) Return $vPropertyValue EndFunc #ce Func UIAEH_NotificationEventHandler_QueryInterface( $pSelf, $pRIID, $pObj ) ; Ret: long Par: ptr;ptr* Switch DllCall( "ole32.dll", "int", "StringFromGUID2", "struct*", $pRIID, "wstr", "", "int", 40 )[2] Case "{00000000-0000-0000-C000-000000000046}" ; $sIID_IUnknown DllStructSetData( DllStructCreate( "ptr", $pObj ), 1, $pSelf ) UIAEH_NotificationEventHandler_AddRef( $pSelf ) Return 0x00000000 ; $S_OK Case $sIID_IUIAutomationNotificationEventHandler ConsoleWrite( "IID_IUIAutomationNotificationEventHandler" & @CRLF ) DllStructSetData( DllStructCreate( "ptr", $pObj ), 1, $pSelf ) UIAEH_NotificationEventHandler_AddRef( $pSelf ) Return 0x00000000 ; $S_OK Case Else Return 0x80004002 ; $E_NOINTERFACE EndSwitch EndFunc Func UIAEH_NotificationEventHandler_AddRef( $pSelf ) ; Ret: ulong Return 1 #forceref $pSelf EndFunc Func UIAEH_NotificationEventHandler_Release( $pSelf ) ; Ret: ulong Return 1 #forceref $pSelf EndFunc An example is shown in Examples\NotificationEventHandlerEx.au3: #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_UseX64=y Opt( "MustDeclareVars", 1 ) #include "..\Includes\UIAEH_NotificationEventHandler.au3" Example() Func Example() UIAEH_NotificationEventHandlerCreate() If Not IsObj( $oUIAEH_NotificationEventHandler ) Then Return ConsoleWrite( "$oUIAEH_NotificationEventHandler ERR" & @CRLF ) ConsoleWrite( "$oUIAEH_NotificationEventHandler OK" & @CRLF ) Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation8, $sIID_IUIAutomation6, $dtag_IUIAutomation6 ) ; Windows 10 Last If Not IsObj( $oUIAutomation ) Then Return ConsoleWrite( "$oUIAutomation ERR" & @CRLF ) ConsoleWrite( "$oUIAutomation OK" & @CRLF ) Local $pDesktop $oUIAutomation.GetRootElement( $pDesktop ) If Not $pDesktop Then Return ConsoleWrite( "$pDesktop ERR" & @CRLF ) ConsoleWrite( "$pDesktop OK" & @CRLF ) Local $iError = $oUIAutomation.AddNotificationEventHandler( $pDesktop, $TreeScope_Subtree, 0, $oUIAEH_NotificationEventHandler ) If $iError Then Return ConsoleWrite( "AddNotificationEventHandler() ERR" & @CRLF ) ConsoleWrite( "AddNotificationEventHandler() OK" & @CRLF ) HotKeySet( "{ESC}", "Quit" ) While Sleep(10) WEnd EndFunc Func Quit() UIAEH_NotificationEventHandlerDelete() Exit EndFunc ; This is the function that receives events Func UIAEH_NotificationEventHandler_HandleNotificationEvent( $pSelf, $pSender, $iKind, $iProcessing, $pDisplayStr, $pActivityId ) ; Ret: long Par: ptr;long;long;ptr;ptr ConsoleWrite( @CRLF & "UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = " & $aNotificationKindNames[$iKind] & @CRLF ) ConsoleWrite( "UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = " & $aNotificationProcessingNames[$iProcessing] & @CRLF ) ConsoleWrite( "UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = " & UIA_String( $pDisplayStr ) & @CRLF ) ConsoleWrite( "UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = " & UIA_String( $pActivityId ) & @CRLF ) Local $oSender = ObjCreateInterface( $pSender, $sIID_IUIAutomationElement9, $dtag_IUIAutomationElement9 ) ; Windows 10 Last $oSender.AddRef() ConsoleWrite( "Title = " & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_NamePropertyId ) & @CRLF & _ "Class = " & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_ClassNamePropertyId ) & @CRLF & _ "Ctrl type = " & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_ControlTypePropertyId ) & @CRLF & _ "Ctrl name = " & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_LocalizedControlTypePropertyId ) & @CRLF & _ "Handle = " & "0x" & Hex( UIAEH_GetCurrentPropertyValue( $oSender, $UIA_NativeWindowHandlePropertyId ) ) & @CRLF & _ "Value = " & UIAEH_GetCurrentPropertyValue( $oSender, $UIA_ValueValuePropertyId ) & @CRLF ) Return 0x00000000 ; $S_OK #forceref $pSelf EndFunc ; Auxiliary function (for simple properties only) ; There must be only one instance of this function Func UIAEH_GetCurrentPropertyValue( $oSender, $iPropertyId ) Local $vPropertyValue $oSender.GetCurrentPropertyValue( $iPropertyId, $vPropertyValue ) Return $vPropertyValue EndFunc Because $pDisplayStr and $pActivityId are Microsoft BSTRs, a new function UIA_String( $pBSTR ) has been added in UIA_Functions.au3 to convert BSTRs to AutoIt strings. Output in SciTE console (creation): Func UIAEH_NotificationEventHandler_QueryInterface( $pSelf ) ; Ret: long Par: ptr;ptr EndFunc 0 Func UIAEH_NotificationEventHandler_AddRef( $pSelf ) ; Ret: dword EndFunc 0 Func UIAEH_NotificationEventHandler_Release( $pSelf ) ; Ret: dword EndFunc 0 Func UIAEH_NotificationEventHandler_HandleNotificationEvent( $pSelf ) ; Ret: long Par: ptr;long;long;ptr;ptr EndFunc 0 $oUIAEH_NotificationEventHandler OK $oUIAutomation OK $pDesktop OK IID_IUIAutomationNotificationEventHandler AddNotificationEventHandler() OK Output in SciTE console (Windows 10 Calculator): UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_ActionCompleted UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Standard Lommeregnertilstand UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = CategoryNameChanged Title = Class = TextBlock Ctrl type = 50020 Ctrl name = sende sms Handle = 0x00000000 Value = UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_Other UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Skærm er 7 UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = DisplayUpdated Title = Class = TextBlock Ctrl type = 50020 Ctrl name = sende sms Handle = 0x00000000 Value = UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_Other UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Skærm er 78 UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = DisplayUpdated Title = Class = TextBlock Ctrl type = 50020 Ctrl name = sende sms Handle = 0x00000000 Value = UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_Other UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Skærm er 789 UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = DisplayUpdated Title = Class = TextBlock Ctrl type = 50020 Ctrl name = sende sms Handle = 0x00000000 Value = UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_Other UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Skærm er 789 gange UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = DisplayUpdated Title = Class = TextBlock Ctrl type = 50020 Ctrl name = sende sms Handle = 0x00000000 Value = UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_Other UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Skærm er 2 UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = DisplayUpdated Title = Class = TextBlock Ctrl type = 50020 Ctrl name = sende sms Handle = 0x00000000 Value = UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_Other UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Skærm er 1.578 UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = DisplayUpdated Title = Class = TextBlock Ctrl type = 50020 Ctrl name = sende sms Handle = 0x00000000 Value = UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_ActionCompleted UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Den viste værdi er kopieret til udklipsholder UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = DisplayCopied Title = Class = TextBlock Ctrl type = 50020 Ctrl name = sende sms Handle = 0x00000000 Value = Output in SciTE console (Microsoft Edge): UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_ActionCompleted UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Loading page UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = LoadingPageBeginsActivityId Title = Class = ScrollViewer Ctrl type = 50033 Ctrl name = pane Handle = 0x00000000 Value = UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_ActionCompleted UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Loading complete UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = LoadingPageCompleteActivityId Title = Class = ScrollViewer Ctrl type = 50033 Ctrl name = pane Handle = 0x00000000 Value = UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_ActionCompleted UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Loading page UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = LoadingPageBeginsActivityId Title = Class = ScrollViewer Ctrl type = 50033 Ctrl name = pane Handle = 0x00000000 Value = UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_ActionCompleted UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Loading complete UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = LoadingPageCompleteActivityId Title = Class = ScrollViewer Ctrl type = 50033 Ctrl name = pane Handle = 0x00000000 Value = UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_ActionCompleted UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Loading page UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = LoadingPageBeginsActivityId Title = Class = ScrollViewer Ctrl type = 50033 Ctrl name = pane Handle = 0x00000000 Value = UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_ActionCompleted UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Loading complete UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = LoadingPageCompleteActivityId Title = Class = ScrollViewer Ctrl type = 50033 Ctrl name = pane Handle = 0x00000000 Value = UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_ActionCompleted UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Loading page UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = LoadingPageBeginsActivityId Title = Class = ScrollViewer Ctrl type = 50033 Ctrl name = pane Handle = 0x00000000 Value = UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_ActionCompleted UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Loading complete UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = LoadingPageCompleteActivityId Title = Class = ScrollViewer Ctrl type = 50033 Ctrl name = pane Handle = 0x00000000 Value = UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_ActionCompleted UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Going back UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = GoingBackActivityId Title = Back Class = Button Ctrl type = 50000 Ctrl name = button Handle = 0x00000000 Value = UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_ActionCompleted UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Loading page UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = LoadingPageBeginsActivityId Title = Class = ScrollViewer Ctrl type = 50033 Ctrl name = pane Handle = 0x00000000 Value = UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_ActionCompleted UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Loading complete UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = LoadingPageCompleteActivityId Title = Class = ScrollViewer Ctrl type = 50033 Ctrl name = pane Handle = 0x00000000 Value = UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_ActionCompleted UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Going back UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = GoingBackActivityId Title = Back Class = Button Ctrl type = 50000 Ctrl name = button Handle = 0x00000000 Value = UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_ActionCompleted UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Loading page UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = LoadingPageBeginsActivityId Title = Class = ScrollViewer Ctrl type = 50033 Ctrl name = pane Handle = 0x00000000 Value = UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_ActionCompleted UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Loading complete UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = LoadingPageCompleteActivityId Title = Class = ScrollViewer Ctrl type = 50033 Ctrl name = pane Handle = 0x00000000 Value = UIAEH_NotificationEventHandler_HandleNotificationEvent: $iKind = $NotificationKind_ActionCompleted UIAEH_NotificationEventHandler_HandleNotificationEvent: $iProcessing = $NotificationProcessing_ImportantMostRecent UIAEH_NotificationEventHandler_HandleNotificationEvent: $sDisplayStr = Closing tab UIAEH_NotificationEventHandler_HandleNotificationEvent: $sActivityId = ClosingTabActivityId Title = AutoIt Example Scripts - AutoIt Forums tab Class = GridViewItem Ctrl type = 50025 Ctrl name = Handle = 0x00000000 Value = AutomationEventHandler For the existing AutomationEventHandler and for the other existing event handlers, comment lines have been added in both the UDF and the example about which version of the UIA objects to use. Comment lines are added like this: Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtag_IUIAutomation ) ; Windows 7 ;Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation8, $sIID_IUIAutomation2, $dtag_IUIAutomation2 ) ; Windows 8 ;Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation8, $sIID_IUIAutomation3, $dtag_IUIAutomation3 ) ; Windows 8.1 ;Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation8, $sIID_IUIAutomation3, $dtag_IUIAutomation3 ) ; Windows 10 First ;Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation8, $sIID_IUIAutomation6, $dtag_IUIAutomation6 ) ; Windows 10 Last Local $oSender = ObjCreateInterface( $pSender, $sIID_IUIAutomationElement, $dtag_IUIAutomationElement ) ; Windows 7 ;Local $oSender = ObjCreateInterface( $pSender, $sIID_IUIAutomationElement2, $dtag_IUIAutomationElement2 ) ; Windows 8 ;Local $oSender = ObjCreateInterface( $pSender, $sIID_IUIAutomationElement3, $dtag_IUIAutomationElement3 ) ; Windows 8.1 ;Local $oSender = ObjCreateInterface( $pSender, $sIID_IUIAutomationElement4, $dtag_IUIAutomationElement4 ) ; Windows 10 First ;Local $oSender = ObjCreateInterface( $pSender, $sIID_IUIAutomationElement9, $dtag_IUIAutomationElement9 ) ; Windows 10 Last UIAEHEvents.au3 updates In order for UI Automation Event Monitor to be able to detect new events and property changes, the code has been updated to handle different Windows versions and thus different versions of the UIA objects. Handling multiple versions of Windows and multiple versions of the UIA objects is the same as in UIASpy. Through a new Options menu you can execute code that fits a particular Windows version. Note that under Windows 7 and earlier versions, only the original four event handlers (AutomationEventHandler, FocusChangedEventHandler, PropertyChangedEventHandler, StructureChangedEventHandler) introduced in Windows 7 can be used. In addition, some minor errors have been fixed and some of the code has been tightened up. New zip-file at bottom of first post.
    1 point
  6. I have recompiled the dll and updated the source code. Tried in VMW and it worked fine. Please download the updated version.
    1 point
  7. I think the problem is that you have given the focus to "Enter initial" and never got fully back. Maybe because the password is not sent correctly, (btw you should have a sleep between mouseclick and send). Anyway it is hard to say without a runable script that replicates your issue. Nevertheless, I was able to try something with notepad. It is not exactly your situation, but it is close and I lost control of the GUI, so I solved my problem this way : Local $hGUI = GUICreate ("Test") Local $idButton = GUICtrlCreateButton ("OK", 20,50,100,25) GUISetState () Local $c, $aPos, $bAttempted = False While 1 If Not $bAttempted And WinExists("[CLASS:Notepad]") Then Local $c = WinActivate("[CLASS:Notepad]") WinWaitActive($c) Sleep(200) If $c = 0 Then Exit MsgBox(0, 0, "error") Local $aPos = WinGetPos($c) If @error Then Exit MsgBox(0, 0, 0) ConsoleWrite(@CRLF & $aPos[0] & " " & $aPos[1] & " " & $aPos[2] & " " & @CRLF) MouseClick("Primary", $aPos[0] + 125, $aPos[1] + 125, 1, 1) Sleep (800) Send("password") Send("{Enter}") Sleep (2000) If WinExists ($c) Then ConsoleWrite ("Wrong password" & @CRLF) $bAttempted = True EndIf Switch GUIGetMsg() Case $idButton Exit EndSwitch WEnd ps. this is the way to debug a program. Make a smaller replicate of the problem and then it is easier to find solution.
    1 point
  8. Not sure if the Compress-Archive method will collect the stream data and embed it in an archive, then put it back in place when the file is extracted. You might have to do a custom script to extract the stream data and add it to the archive, then a archive extraction process to "rebuild" the streams. I saw an article that says the RAR file format supports NTFS ADS, but haven't looked into it.
    1 point
×
×
  • Create New...