Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/15/2020 in all areas

  1. Trong

    ImageSearchUDF

    Version v3.5

    11,603 downloads

    ImageSearch UDF v3.5 - AutoIt Wrapper for ImageSearchDLL Advanced image search library for AutoIt with cache system and SIMD optimization. Overview ImageSearchDLL UDF is a high-performance image search library for AutoIt that enables you to find images on screen or within other images. Built with C++14 and optimized with SIMD instructions (AVX512/AVX2/SSE2), it provides fast and accurate image matching capabilities. Features High Performance: SIMD optimization (AVX512/AVX2/SSE2) for fast searching Multi-Monitor Support: Full support for multi-monitor setups with negative coordinates DPI Awareness: Thread-local DPI awareness without affecting AutoIt GUI Cache System: Persistent cache for 30-50% speed boost on repeated searches Image Scaling: Search for images at different scales (0.1x to 5.0x) Screen Capture: Direct screen capture with DPI-aware coordinates Mouse Automation: Precise mouse movement and clicking with multi-monitor support Requirements AutoIt: Version 3.3.16.1 or higher Windows: XP SP3 to Windows 11 Architecture: x86 or x64 (automatic detection) DLL: ImageSearchDLL v3.5 (included) Installation Download the UDF package Place ImageSearchDLL_UDF.au3 in your script directory Ensure the appropriate DLL is in the same directory: ImageSearchDLL_x64.dll for 64-bit AutoIt ImageSearchDLL_x86.dll for 32-bit AutoIt Not required in embedded version! (But need to install Visual C++ Redistributable 2015-2022) Include the UDF in your script: #include "ImageSearchDLL_UDF.au3" Quick Start Basic Image Search #include "ImageSearchDLL_UDF.au3" ; Search for a button on screen Local $aResult = _ImageSearch("button.png") If $aResult[0] > 0 Then ConsoleWrite("Found at: " & $aResult[1][0] & ", " & $aResult[1][1] & @CRLF) MouseClick("left", $aResult[1][0], $aResult[1][1]) Else ConsoleWrite("Image not found" & @CRLF) EndIf Wait for Image and Click ; Wait up to 5 seconds for button to appear, then click it If _ImageSearch_WaitClick(5000, "button.png") Then MsgBox(0, "Success", "Button clicked!") Else MsgBox(0, "Failed", "Button not found within 5 seconds") EndIf Screen Capture ; Capture a region and save as PNG _ImageSearch_ScreenCapture_SaveImage(@ScriptDir & "\screenshot.png", 100, 100, 600, 400) ; Capture full screen _ImageSearch_ScreenCapture_SaveImage(@ScriptDir & "\fullscreen.png") API Reference Startup & Configuration _ImageSearch_Startup() Initializes the ImageSearch library by loading the appropriate DLL. Returns: Success: 1 (DLL loaded successfully) Failure: 0 and sets @error Remarks: Must be called before using any search functions Automatically called on script start DLL v3.5+ uses thread-local DPI awareness and won't affect AutoIt GUI _ImageSearch_Shutdown() Closes the DLL and cleans up resources. _ImageSearch_SetDllPath($sPath) Sets a custom DLL path (must be called before _ImageSearch_Startup). Parameters: $sPath - Full path to the DLL file Returns: Success: 1 Failure: 0 (file not found) Core Search Functions _ImageSearch($sImagePath [, $iLeft, $iTop, $iRight, $iBottom [, $iScreen [, $iTolerance [, $iResults [, $iCenterPOS [, $fMinScale [, $fMaxScale [, $fScaleStep [, $iReturnDebug [, $iUseCache]]]]]]]]) Searches for an image within a specified screen area. Parameters: $sImagePath - Image file path(s), multiple separated by "|" $iLeft, $iTop, $iRight, $iBottom - Search region (0 = entire screen) $iScreen - Monitor index (-1 = virtual screen, 0 = primary, 1+ = specific monitor) $iTolerance - Color tolerance 0-255 (default: 10) $iResults - Max results 1-1024 (default: 1) $iCenterPOS - Return center (1) or top-left (0) coordinates (default: 1) $fMinScale, $fMaxScale - Scale range 0.1-5.0 (default: 1.0) $fScaleStep - Scale step (default: 0.1) $iReturnDebug - Debug mode (default: 0) $iUseCache - Enable cache (default: 1) Returns: Success: Array of found positions [count][X, Y, Width, Height] Failure: Empty array with @error set Example: ; Search for multiple images with scaling Local $aResult = _ImageSearch("icon1.png|icon2.png", 0, 0, 800, 600, -1, 10, 5, 1, 0.8, 1.2, 0.1) If $aResult[0] > 0 Then For $i = 1 To $aResult[0] ConsoleWrite("Match " & $i & " at: " & $aResult[$i][0] & ", " & $aResult[$i][1] & @CRLF) Next EndIf _ImageSearch_InImage($sSourceImage, $sTargetImage [, $iTolerance [, $iResults [, $iCenterPOS [, $fMinScale [, $fMaxScale [, $fScaleStep [, $iReturnDebug [, $iUseCache]]]]]]]]) Searches for a target image within a source image (file-to-file search). Parameters: $sSourceImage - Path to source image file $sTargetImage - Path to target image file(s), multiple separated by "|" Other parameters same as _ImageSearch Returns: Same as _ImageSearch Remarks: Useful for pre-processing images or testing without screen capture Example: $aResult = _ImageSearch_InImage("screenshot.png", "button.png", 20) _ImageSearch_hBitmap($hBitmapSource, $hBitmapTarget [, $iTolerance [, $iLeft [, $iTop [, $iRight [, $iBottom [, $iResults [, $iCenterPOS [, $fMinScale [, $fMaxScale [, $fScaleStep [, $iReturnDebug [, $iUseCache]]]]]]]]]]]]) Searches for a target bitmap within a source bitmap (memory-to-memory search). Parameters: $hBitmapSource - Handle to source bitmap (HBITMAP) $hBitmapTarget - Handle to target bitmap (HBITMAP) Other parameters same as _ImageSearch Returns: Same as _ImageSearch Remarks: Fastest method for repeated searches (no disk I/O) Bitmaps must be created with GDI/GDI+ functions Screen Capture Functions _ImageSearch_CaptureScreen([$iLeft, $iTop, $iRight, $iBottom [, $iScreen]]) Capture screen region and return as HBITMAP handle. Parameters: $iLeft, $iTop, $iRight, $iBottom - Capture region (default: 0 = full screen) $iScreen - Monitor index (default: -1 = virtual screen) Returns: Success: HBITMAP handle (must DeleteObject when done) Failure: 0 and sets @error Example: $hBitmap = _ImageSearch_CaptureScreen(0, 0, 800, 600) ; ... use $hBitmap ... _WinAPI_DeleteObject($hBitmap) _ImageSearch_ScreenCapture_SaveImage($sImageFile [, $iLeft [, $iTop [, $iRight [, $iBottom [, $iScreen]]]]]) Captures a screen region and saves it directly to an image file in one call. Parameters: $sImageFile - Output file path (extension determines format: .bmp, .png, .jpg/.jpeg) $iLeft, $iTop, $iRight, $iBottom - Capture region (default: 0 = full screen) $iScreen - Monitor index (default: 0 = primary screen) Returns: Success: True (1) Failure: False (0) and sets @error Remarks: Automatically detects format from file extension ~2x faster than separate capture + save operations JPEG quality is fixed at 100% (highest quality) Uses DPI-aware capture (accurate on all DPI scales) Example: ; Capture full primary screen to PNG _ImageSearch_ScreenCapture_SaveImage(@ScriptDir & "\screenshot.png") ; Capture region on monitor 2 to JPEG _ImageSearch_ScreenCapture_SaveImage(@ScriptDir & "\region.jpg", 100, 100, 600, 400, 2) _ImageSearch_hBitmapLoad($sImageFile [, $iAlpha [, $iRed [, $iGreen [, $iBlue]]]]) Load image file and convert to HBITMAP handle. Parameters: $sImageFile - Path to image file $iAlpha, $iRed, $iGreen, $iBlue - Background color components 0-255 (default: 0 = transparent) Returns: Success: HBITMAP handle (must DeleteObject when done) Failure: 0 and sets @error Example: $hBitmap = _ImageSearch_hBitmapLoad("image.png", 255, 255, 255, 255) ; White background ; ... use $hBitmap ... _WinAPI_DeleteObject($hBitmap) Mouse Functions _ImageSearch_MouseMove($iX, $iY [, $iSpeed [, $iScreen]]) Moves mouse cursor to coordinates (supports negative coordinates on multi-monitor). Parameters: $iX, $iY - Target coordinates (-1 = keep current position) $iSpeed - Speed 0-100 (0=instant, default: 0) $iScreen - Monitor index (default: -1 = virtual screen) Returns: 1 on success, 0 on failure _ImageSearch_MouseClick([$sButton [, $iX [, $iY [, $iClicks [, $iSpeed [, $iScreen]]]]]]) Clicks mouse at coordinates (screen or current position). Parameters: $sButton - Button: "left", "right", "middle" (default: "left") $iX, $iY - Coordinates (-1 = current position) $iClicks - Number of clicks (default: 1) $iSpeed - Speed 0-100 (0=instant, default: 0) $iScreen - Monitor index (default: -1 = virtual screen) Returns: 1 on success, 0 on failure _ImageSearch_MouseClickWin($sTitle, $sText, $iX, $iY [, $sButton [, $iClicks [, $iSpeed]]]) Clicks mouse in a window. Parameters: $sTitle - Window title/class/handle $sText - Window text $iX, $iY - Relative coordinates in window $sButton - Button (default: "left") $iClicks - Number of clicks (default: 1) $iSpeed - Speed 0-100 (default: 0) Returns: 1 on success, 0 on failure Wait & Click Functions _ImageSearch_Wait($iTimeout, $sImagePath [, $iLeft [, $iTop [, $iRight [, $iBottom [, $iScreen [, $iTolerance [, $iResults [, $iCenterPOS [, $fMinScale [, $fMaxScale [, $fScaleStep [, $iReturnDebug [, $iUseCache [, $iMaxAttempts]]]]]]]]]]]]]) Waits for an image to appear on screen with timeout and optional max attempts limit. Parameters: $iTimeout - Timeout in milliseconds (0 = wait forever) $sImagePath - Image file path(s), multiple separated by "|" $iMaxAttempts - Max number of search attempts (0 = unlimited, default: 0) Other parameters same as _ImageSearch Returns: Success: 2D Array (same as _ImageSearch) Timeout: Empty array with [0][0] = 0 Example: ; Wait 5 seconds for button (unlimited attempts) $aResult = _ImageSearch_Wait(5000, "button.png") If $aResult[0] > 0 Then MouseClick("left", $aResult[1][0], $aResult[1][1]) Else MsgBox(0, "Timeout", "Button not found") EndIf _ImageSearch_WaitClick($iTimeout, $sImagePath [, $sButton [, $iClicks [, $iLeft [, $iTop [, $iRight [, $iBottom [, $iScreen [, $iTolerance [, $iResults [, $iCenterPOS [, $fMinScale [, $fMaxScale [, $fScaleStep [, $iReturnDebug [, $iUseCache]]]]]]]]]]]]]) Waits for an image and clicks it when found. Parameters: $iTimeout - Timeout in milliseconds (0 = wait forever) $sImagePath - Image file path(s) $sButton - Mouse button: "left", "right", "middle" (default: "left") $iClicks - Number of clicks (default: 1) Other parameters same as _ImageSearch Returns: Success: 1 (image found and clicked) Timeout: 0 (image not found) Monitor Functions _ImageSearch_Monitor_GetList() Gets a list of all connected display monitors and their properties. Returns: Success: The number of monitors found. @extended contains a detailed log. Failure: 0 and sets @error Remarks: Populates the global $g_aMonitorList Called automatically by _ImageSearch_Startup _ImageSearch_Monitor_ToVirtual($iMonitor, $iX, $iY) Converts local monitor coordinates to virtual screen coordinates. Parameters: $iMonitor - The 1-based index of the monitor $iX, $iY - Coordinates relative to the monitor's top-left corner Returns: Success: A 2-element array [$vX, $vY] containing virtual screen coordinates Failure: 0 and sets @error _ImageSearch_Monitor_FromVirtual($iMonitor, $iX, $iY) Converts virtual screen coordinates to local monitor coordinates. Parameters: $iMonitor - The 1-based index of the monitor $iX, $iY - Virtual screen coordinates Returns: Success: A 2-element array [$lX, $lY] containing local monitor coordinates Failure: 0 and sets @error _ImageSearch_Monitor_Current() Detects which monitor contains the current mouse cursor position. Returns: Success: Monitor index (1-based) where the cursor is located Failure: 0 and sets @error _ImageSearch_Monitor_GetAtPosition([$iX [, $iY]]) Returns detailed information string about the monitor at specified position. Parameters: $iX, $iY - Coordinates (default: -1 = use mouse cursor position) Returns: Success: String describing the monitor (e.g., "Monitor 2: 1920x1080 (Primary)") Failure: Error message string Window Coordinate Functions _ImageSearch_Window_ToScreen($hWnd, $iX, $iY [, $bClientArea]) Converts window-relative coordinates to screen (virtual desktop) coordinates. Parameters: $hWnd - Window handle or title $iX, $iY - Coordinates relative to window $bClientArea - True = relative to client area, False = relative to window (default: True) Returns: Success: A 2-element array [$screenX, $screenY] containing screen coordinates Failure: 0 and sets @error _ImageSearch_Window_FromScreen($hWnd, $iScreenX, $iScreenY [, $bClientArea]) Converts screen (virtual desktop) coordinates to window-relative coordinates. Parameters: $hWnd - Window handle or title $iScreenX, $iScreenY - Screen coordinates $bClientArea - True = relative to client area, False = relative to window (default: True) Returns: Success: A 2-element array [$winX, $winY] containing window-relative coordinates Failure: 0 and sets @error Cache & Info Functions _ImageSearch_WarmUpCache($sImagePaths [, $bEnableCache]) Pre-loads images into cache for faster subsequent searches. Parameters: $sImagePaths - Pipe-separated list of images to preload $bEnableCache - Enable persistent cache (default: True) Returns: Success: Number of images cached Failure: 0 Example: _ImageSearch_WarmUpCache("btn1.png|btn2.png|icon.png") _ImageSearch_ClearCache() Clears the internal bitmap and location cache. Remarks: Useful for freeing memory or forcing re-scan after image updates Clears both in-memory cache and persistent disk cache _ImageSearch_GetDllInfo([$bForceRefresh]) Gets comprehensive DLL information in INI format. Parameters: $bForceRefresh - Force refresh of cached info (default: True) Returns: Multi-line string in INI format with sections: [DLL] - DLL name, version, architecture, author [OS] - OS name, version, build, platform [CPU] - Threads, SSE2, AVX2, AVX512 support [SCREEN] - Virtual screen, scale, monitors with individual resolutions [CACHE] - Location cache, bitmap cache, pool size _ImageSearch_GetInfo() Gets formatted DLL and system information for display. Returns: Formatted string with DLL info, cache status, and screen information _ImageSearch_GetDllValue($sSection, $sKey) Quick accessor to read any value from cached DLL Info. Parameters: $sSection - Section name (DLL, OS, CPU, SCREEN, CACHE) $sKey - Key name Returns: Value string or "" if not found Example: $sVersion = _ImageSearch_GetDllValue("DLL", "Version") $sOSName = _ImageSearch_GetDllValue("OS", "Name") $iThreads = _ImageSearch_GetDllValue("CPU", "Threads") _ImageSearch_GetLastResult() Gets the raw DLL return string from the last search. Returns: Raw result string (e.g., "{2}[100|200|32|32,150|250|32|32]") Remarks: Useful for debugging or custom parsing _ImageSearch_GetScale([$iScreen]) Gets the DPI scale factor for a specific monitor as a decimal number. Parameters: $iScreen - Monitor index (0 = Primary, 1+ = specific monitor number) Returns: Scale factor as number (e.g., 1.0, 1.25, 1.5) or 0 if not found Example: $fScale = _ImageSearch_GetScale(0) ; Get primary monitor scale (e.g., 1.25) $fScale = _ImageSearch_GetScale(2) ; Get monitor 2 scale Examples Advanced Search with Multiple Images and Scaling #include "ImageSearchDLL_UDF.au3" ; Search for multiple UI elements with different scales Local $sImages = "button_ok.png|button_cancel.png|icon_settings.png" Local $aResult = _ImageSearch($sImages, 0, 0, 1920, 1080, -1, 15, 10, 1, 0.8, 1.3, 0.1, 0, 1) If $aResult[0] > 0 Then ConsoleWrite("Found " & $aResult[0] & " matches:" & @CRLF) For $i = 1 To $aResult[0] ConsoleWrite(" Match " & $i & ": X=" & $aResult[$i][0] & ", Y=" & $aResult[$i][1] & ", W=" & $aResult[$i][2] & ", H=" & $aResult[$i][3] & @CRLF) Next Else ConsoleWrite("No matches found" & @CRLF) EndIf Multi-Monitor Screen Capture #include "ImageSearchDLL_UDF.au3" ; Get monitor information _ImageSearch_Monitor_GetList() ConsoleWrite("Detected " & $g_aMonitorList[0][0] & " monitors" & @CRLF) ; Capture each monitor separately For $i = 1 To $g_aMonitorList[0][0] Local $sFile = @ScriptDir & "\monitor_" & $i & ".png" _ImageSearch_ScreenCapture_SaveImage($sFile, 0, 0, 0, 0, $i) ConsoleWrite("Captured monitor " & $i & " to: " & $sFile & @CRLF) Next ; Capture entire virtual desktop _ImageSearch_ScreenCapture_SaveImage(@ScriptDir & "\virtual_desktop.png", 0, 0, 0, 0, -1) Automated UI Testing #include "ImageSearchDLL_UDF.au3" ; Pre-load images for better performance _ImageSearch_WarmUpCache("login_button.png|username_field.png|password_field.png") ; Wait for login screen and interact If _ImageSearch_WaitClick(10000, "login_button.png") Then ConsoleWrite("Login button clicked" & @CRLF) ; Find username field and click Local $aUsername = _ImageSearch_Wait(5000, "username_field.png") If $aUsername[0] > 0 Then MouseClick("left", $aUsername[1][0], $aUsername[1][1]) Send("myusername") ; Find password field and click Local $aPassword = _ImageSearch_Wait(5000, "password_field.png") If $aPassword[0] > 0 Then MouseClick("left", $aPassword[1][0], $aPassword[1][1]) Send("mypassword") Send("{ENTER}") EndIf EndIf Else MsgBox(0, "Error", "Login screen not found within 10 seconds") EndIf Error Codes Code Constant Description -1 $IMGSE_INVALID_PATH Invalid file path -2 $IMGSE_FAILED_TO_LOAD_IMAGE Failed to load image -3 $IMGSE_FAILED_TO_GET_SCREEN_DC Failed to get screen device context -4 $IMGSE_INVALID_SEARCH_REGION Invalid search region -5 $IMGSE_INVALID_PARAMETERS Invalid parameters -6 $IMGSE_INVALID_SOURCE_BITMAP Invalid source bitmap -7 $IMGSE_INVALID_TARGET_BITMAP Invalid target bitmap -9 $IMGSE_RESULT_TOO_LARGE Result too large -10 $IMGSE_INVALID_MONITOR Invalid monitor Performance Tips Use Cache: Enable cache for repeated searches to get 30-50% speed boost Pre-load Images: Use _ImageSearch_WarmUpCache() during initialization Limit Search Area: Specify search regions instead of full screen when possible Optimize Tolerance: Use appropriate tolerance values (5-15 for most cases) Use Appropriate Scale Range: Limit scale range to what you actually need Monitor Selection: Use specific monitor index for faster searches on multi-monitor setups Image Format: BMP files load faster than PNG/JPG but are larger Memory Management: Always call _WinAPI_DeleteObject() for HBITMAP handles Changelog Version 3.5 Added thread-local DPI awareness (no GUI resize issues) Enhanced multi-monitor support with individual monitor scales Improved cache system with persistent disk cache Added _ImageSearch_ScreenCapture_SaveImage() for direct file saving Performance optimizations with SIMD instructions Better error handling and debugging information License This project is licensed under the MIT License - see the LICENSE file for details. Author Dao Van Trong - TRONG.PRO Thank you for using ImageSearch UDF! 🚀 ☕ Support My Work Enjoy my work? Buy me a 🍻 or tip via ❤️ PayPal Happy Automating! 🚀 ___________________________
    1 point
  2. LAST VERSION - 1.1 18-May-12 Control Viewer (CV) is a replacement of AutoIt Window Info with a number of advantages. I tried to stick to the interface of the last, so you almost do not have to be retrained. During testing, I never managed to find any controls that could not be identified by CV (on the contrary, shows a lot of hidden controls, especially for the system windows). The all program settings are stored in the following registry key: HKEY_CURRENT_USERSoftwareY'sControl Viewer The main differences CV from AWI Shows the complete list of all existing controls for the window that are interested (visible, hidden and deleted controls are displayed with different colors that can be changed to any other).Dynamically changing information during search for the windows and their controls.Ability to quickly switch between controls in the list.Ability to show/hide any controls from the list (useful for the overlaping controls).Information for the Style and ExStyle parameters shown in the form of hexadecimal values​​, and as its flags.Added the PID and Path parameters in the Window tab and ability to quickly open a folder that containing the process file.Added the coordinate system relative to the selected control.Shows a color of the selected pixel in RGB and BGR formats.Shows an example fill of the selected color.Ability to select the text encoding (affects the Text parameter in the Control tab).The complete change the appearance of pop-up frame for the selected controls.Simple and convenient tool to get a screenshot of the part screen of interest for publication on the forum (Capture tab).Create a report in the clipboard or a text file for subsequent publication on the forum.Search all running AutoIt scripts and their windows in the system (AutoIt tab).User-friendly interface. Used shortcuts Ctrl+Alt+T - Enable/Disable "Always On Top" mode (also available from the menu). Ctrl+Alt+H - Enable/Disable highlight selected controls (also available from the menu). Ctrl+A - Select all text (works in any input field). Ctrl - Hold down when moving the mouse to scroll the screenshot (Capture tab). Shift - Hold down when stretching/compression of the contour frame for an equilateral resizing screenshots (Capture tab). DoubleClick (on the screenshot) - Save the image to a file (Capture tab). DoubleClick (on any list item) - Open a folder with the file of the process or AutoIt script (AutoIt tab). Del (on any list item) - Close process (AutoIt tab). F5 - Updating the list (AutoIt tab). If anyone have any questions or comments about CV, please post it in this thread. I will be glad to any feedback and suggestions. Files to download Binary (x86 and x64) Redirection to CV_bin.zip, 1.14 MB CV_bin.html Source Redirection to CV_source.zip, 691 KB CV_source.html
    1 point
  3. This is a new program of mine, and still under development, which you can read a kind of blog about at the forum here. It is currently fully working, if you use TeraCopy (at least the older free version I use - 2.27), and you may be able to get it to work with other copier programs. Please let me know if I need to add support for something specific, command-line wise. NOTE - Many aspects have only had minimal testing at this point. Latest Screenshots Here are some early details (from May 27-28), mentioned in a spoiler section here, but reproduced as an edited version. Here is the current download (including source), which you can try out. Keep Track Copier.zip (10 prior downloads) Keep Track Copier v1.1.zip
    1 point
  4. @Clayson Please post your revised code so that I can see your changes. FWIW, I'm in the process of writing the function _WD_ElementActionEx, which will allow you to do things like this more easily. Right now, I have coding for these actions: hover, dblclick, and rgtclick. I'll add more as I think of them or receive suggestions.
    1 point
  5. Did you actually try anything? like: Local $code=StringRegExpReplace($Msga ,'\D*(\d*)\D*','$1') Jos
    1 point
  6. This one is easy... just use contains -- _WD_FindElement($sSession, $_WD_LOCATOR_ByXPath, '//*[@type="radio" and contains(text(), "Radio B")]') Not sure that I understand your question. Maybe you need to retrieve all Div elements with that particular title and then process them to gather the details you are after. <shrug>
    1 point
  7. VAN0, No, please stick to your own thread as this has nothing to do with my UDF. M23
    1 point
  8. If you have access to the same network shares from your PC and the system you are remoting into, then download and use the standalone AutoIt version and save it to a network share. You can then create and run scripts from the system you are remoting into. UNLESS you are actually running the Applications only via RDP and not actually logging into a desktop. Then, you are out of luck.
    1 point
  9. I am working on a tokensizer which will be the first stage in parsing, some call it the scanner phase. It is basically taking the raw text and converting it into tokens (variable, string, number, operator, keyword etc.), which are much easier to work with in code, the next step would be syntactic analysis, which is just a fancy word to describe to process of checking if the tokens are in the right order (e.x. checking if 123 = $number is in the right order... spoiler alert: it is not in the right order). As usual, not much work code wise but I have a plan in my mind now, and I spent most of my time today researching how enumerators work in C and if linked-lists are really the best way to store dynamically allocated data. Another nice thing is that I have finally created a repository with the code: https://github.com/DcodingTheWeb/EasyCodeIt The code is very basic right now, it just prints the contents of the script to the standard output, I will update it as I work on features. Don't forget to give the repository a 🌟 star if you like what I am doing
    1 point
  10. Correct... You just configured SciTE to open an instance for each file separately and stop checking whether an instance of SciTE is already running. There is one ....sort of: https://groups.google.com/forum/?utm_source=digest&utm_medium=email#!forum/scite The version I publish can be ran portable at which time the user config files will be located within the directory the program is stored and all SCITE related Environment variables need to be removed. Jos
    1 point
  11. I've tested the header color example as 64 bit code on both Windows 7 and Windows 10. In both cases, it fails. There are no colors in the header. Then I've made a much smaller example that only contains header colors: #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 <GUIConstants.au3> #include <GuiListView.au3> Global $hHeader, $aHdrTexts[8] Example() Func Example() ; Create GUI GUICreate( "ListView Header Colors - GUIRegisterMsg", 840, 420 ) ; Create ListView Local $idListView = GUICtrlCreateListView( "", 10, 10, 820, 400 ) _GUICtrlListView_SetExtendedListViewStyle ( $idListView, $LVS_EX_FULLROWSELECT ) ; Add columns to ListView For $i = 0 To 7 _GUICtrlListView_AddColumn( $idListView, "Column " & $i, 99 ) $aHdrTexts[$i] = "Column " & $i Next ; Fill ListView For $i = 0 To 99 GUICtrlCreateListViewItem( $i & "/0|" & $i & "/1|" & $i & "/2|" & $i & "/3|" & _ $i & "/4|" & $i & "/5|" & $i & "/6|" & $i & "/7|", $idListView ) Next ; Header control $hHeader = _GUICtrlListView_GetHeader( $idListView ) ; Register WM_NOTIFY message handler GUIRegisterMsg( 0x004E, "WM_NOTIFY" ) ; 0x004E = $WM_NOTIFY ; Show GUI GUISetState( @SW_SHOW ) ; Message loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Cleanup GUIDelete() EndFunc ; WM_NOTIFY message handler Func WM_NOTIFY( $hWnd, $iMsg, $wParam, $lParam ) Local Static $hHdrBrush = _WinAPI_CreateSolidBrush( 0xCCFFFF ) ; Yellow, BGR Local $tNMHDR = DllStructCreate( $tagNMHDR, $lParam ), $hWndFrom = HWnd( DllStructGetData( $tNMHDR, "hWndFrom" ) ), $iCode = DllStructGetData( $tNMHDR, "Code" ) Switch $hWndFrom Case $hHeader Switch $iCode Case $NM_CUSTOMDRAW Local $tNMCustomDraw = DllStructCreate( $tagNMLVCUSTOMDRAW, $lParam ) Local $dwDrawStage = DllStructGetData( $tNMCustomDraw, "dwDrawStage" ) Switch $dwDrawStage ; Holds a value that specifies the drawing stage Case $CDDS_PREPAINT ; Before the paint cycle begins ConsoleWrite( "CDDS_PREPAINT" & @CRLF ) Return $CDRF_NOTIFYITEMDRAW ; Notify parent window of any item related drawing operations Case $CDDS_ITEMPREPAINT ; Before an item is drawn: Default painting (frames and background) ConsoleWrite( "CDDS_ITEMPREPAINT" & @CRLF ) Return $CDRF_NOTIFYPOSTPAINT ; Notify parent window of any post item related drawing operations Case $CDDS_ITEMPOSTPAINT ; After an item is drawn: Custom painting (item texts) ConsoleWrite( "CDDS_ITEMPOSTPAINT" & @CRLF ) Local $iIndex = DllStructGetData( $tNMCustomDraw, "dwItemSpec" ) ; Item index Local $hDC = DllStructGetData( $tNMCustomDraw, "hdc" ) ; Device context _WinAPI_SetBkMode( $hDC, $TRANSPARENT ) ; Transparent background Local $tRECT = DllStructCreate( $tagRECT ) DllStructSetData( $tRECT, 1, DllStructGetData( $tNMCustomDraw, 6 ) + 1 ) DllStructSetData( $tRECT, 2, DllStructGetData( $tNMCustomDraw, 7 ) + 1 ) DllStructSetData( $tRECT, 3, DllStructGetData( $tNMCustomDraw, 8 ) - 2 ) DllStructSetData( $tRECT, 4, DllStructGetData( $tNMCustomDraw, 9 ) - 2 ) _WinAPI_FillRect( $hDC, $tRECT, $hHdrBrush ) ; Background color DllStructSetData( $tNMCustomDraw, "Left", DllStructGetData( $tNMCustomDraw, "Left" ) + 4 ) ; Left margin DllStructSetData( $tNMCustomDraw, "Right", DllStructGetData( $tNMCustomDraw, "Right" ) - 4 ) ; Right margin DllCall( "user32.dll", "int", "DrawTextW", "handle", $hDC, "wstr", $aHdrTexts[$iIndex], "int", StringLen( $aHdrTexts[$iIndex] ), "struct*", DllStructGetPtr( $tNMCustomDraw, "Left" ), "uint", $DT_LEFT+$DT_SINGLELINE+$DT_VCENTER ) ; _WinAPI_DrawText Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG #forceref $hWnd, $iMsg, $wParam EndFunc It fails the same way. Then I've replaced the GUIRegisterMsg technique with the Subclassing technique: #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 <GUIConstants.au3> #include <GuiListView.au3> Global $hHeader, $aHdrTexts[8] Example() Func Example() ; Create GUI GUICreate( "ListView Header Colors - Subclassing", 840, 420 ) ; Create ListView Local $idListView = GUICtrlCreateListView( "", 10, 10, 820, 400 ) _GUICtrlListView_SetExtendedListViewStyle ( $idListView, $LVS_EX_FULLROWSELECT ) Local $hListView = GUICtrlGetHandle( $idListView ) ; Add columns to ListView For $i = 0 To 7 _GUICtrlListView_AddColumn( $idListView, "Column " & $i, 99 ) $aHdrTexts[$i] = "Column " & $i Next ; Fill ListView For $i = 0 To 99 GUICtrlCreateListViewItem( $i & "/0|" & $i & "/1|" & $i & "/2|" & $i & "/3|" & _ $i & "/4|" & $i & "/5|" & $i & "/6|" & $i & "/7|", $idListView ) Next ; Header control $hHeader = _GUICtrlListView_GetHeader( $idListView ) ; Register ListView WM_NOTIFY message handler Local $pLV_WM_NOTIFY = DllCallbackGetPtr( DllCallbackRegister( "LV_WM_NOTIFY", "lresult", "hwnd;uint;wparam;lparam;uint_ptr;dword_ptr" ) ) DllCall( "comctl32.dll", "bool", "SetWindowSubclass", "hwnd", $hListView, "ptr", $pLV_WM_NOTIFY, "uint_ptr", 0, "dword_ptr", 0 ) ; $iSubclassId = 0, $pData = 0 ;_WinAPI_SetWindowSubclass( $hListView, $pLV_WM_NOTIFY, 0, 0 ) ; $iSubclassId = 0, $pData = 0 ; Show GUI GUISetState( @SW_SHOW ) ; Message loop While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; Cleanup DllCall( "comctl32.dll", "bool", "RemoveWindowSubclass", "hwnd", $hListView, "ptr", $pLV_WM_NOTIFY, "uint_ptr", 0 ) ; $iSubclassId = 0 ;_WinAPI_RemoveWindowSubclass( $hListView, $pLV_WM_NOTIFY, 0 ) ; $iSubclassId = 0 GUIDelete() EndFunc ; ListView WM_NOTIFY message handler Func LV_WM_NOTIFY( $hWnd, $iMsg, $wParam, $lParam, $iSubclassId, $pData ) If $iMsg <> 0x004E Then Return DllCall( "comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $iMsg, "wparam", $wParam, "lparam", $lParam )[0] ; 0x004E = $WM_NOTIFY Local Static $hHdrBrush = _WinAPI_CreateSolidBrush( 0xCCFFFF ) ; Yellow, BGR Local $tNMHDR = DllStructCreate( $tagNMHDR, $lParam ), $hWndFrom = HWnd( DllStructGetData( $tNMHDR, "hWndFrom" ) ), $iCode = DllStructGetData( $tNMHDR, "Code" ) Switch $hWndFrom Case $hHeader Switch $iCode Case $NM_CUSTOMDRAW Local $tNMCustomDraw = DllStructCreate( $tagNMLVCUSTOMDRAW, $lParam ) Local $dwDrawStage = DllStructGetData( $tNMCustomDraw, "dwDrawStage" ) Switch $dwDrawStage ; Holds a value that specifies the drawing stage Case $CDDS_PREPAINT ; Before the paint cycle begins ConsoleWrite( "CDDS_PREPAINT" & @CRLF ) Return $CDRF_NOTIFYITEMDRAW ; Notify parent window of any item related drawing operations Case $CDDS_ITEMPREPAINT ; Before an item is drawn: Default painting (frames and background) ConsoleWrite( "CDDS_ITEMPREPAINT" & @CRLF ) Return $CDRF_NOTIFYPOSTPAINT ; Notify parent window of any post item related drawing operations Case $CDDS_ITEMPOSTPAINT ; After an item is drawn: Custom painting (item texts) ConsoleWrite( "CDDS_ITEMPOSTPAINT" & @CRLF ) Local $iIndex = DllStructGetData( $tNMCustomDraw, "dwItemSpec" ) ; Item index Local $hDC = DllStructGetData( $tNMCustomDraw, "hdc" ) ; Device context _WinAPI_SetBkMode( $hDC, $TRANSPARENT ) ; Transparent background Local $tRECT = DllStructCreate( $tagRECT ) DllStructSetData( $tRECT, 1, DllStructGetData( $tNMCustomDraw, 6 ) + 1 ) DllStructSetData( $tRECT, 2, DllStructGetData( $tNMCustomDraw, 7 ) + 1 ) DllStructSetData( $tRECT, 3, DllStructGetData( $tNMCustomDraw, 8 ) - 2 ) DllStructSetData( $tRECT, 4, DllStructGetData( $tNMCustomDraw, 9 ) - 2 ) _WinAPI_FillRect( $hDC, $tRECT, $hHdrBrush ) ; Background color DllStructSetData( $tNMCustomDraw, "Left", DllStructGetData( $tNMCustomDraw, "Left" ) + 4 ) ; Left margin DllStructSetData( $tNMCustomDraw, "Right", DllStructGetData( $tNMCustomDraw, "Right" ) - 4 ) ; Right margin DllCall( "user32.dll", "int", "DrawTextW", "handle", $hDC, "wstr", $aHdrTexts[$iIndex], "int", StringLen( $aHdrTexts[$iIndex] ), "struct*", DllStructGetPtr( $tNMCustomDraw, "Left" ), "uint", $DT_LEFT+$DT_SINGLELINE+$DT_VCENTER ) ; _WinAPI_DrawText Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors EndSwitch EndSwitch EndSwitch ; Call next function in subclass chain Return DllCall( "comctl32.dll", "lresult", "DefSubclassProc", "hwnd", $hWnd, "uint", $iMsg, "wparam", $wParam, "lparam", $lParam )[0] #forceref $iSubclassId, $pData EndFunc Here the code works in all 4 situations: Windows 7/10, 32/64 bit. In the GUIRegisterMsg example, only CDDS_PREPAINT notifications are displayed in SciTE console. The problem seems to be that the CDRF_NOTIFYITEMDRAW return values are not received by the operating system. Therefore, the operating system does not generate CDDS_ITEMPREPAINT or CDDS_ITEMPOSTPAINT notifications and the header items are not colored. Because the Subclassing example works, it excludes errors in the $tagNMLVCUSTOMDRAW structure. It seems like there is an error in the internal AutoIt code associated with the GUIRegisterMsg function when the code is run as 64 bit code. The return values from the WM_NOTIFY message handler are not properly forwarded to the operating system. The error seems also to be related to the fact that the header control is a second level child in relation to the GUI. Colors does work for a listview control which is a first level child. Solution: Implement the WM_NOTIFY message handler in GUIListViewEx.au3 using the Subclassing technique. This is not necessarily completely trivial. In my example above, it looks easy. But this is also a very small example. Lars.
    1 point
×
×
  • Create New...