Leaderboard
Popular Content
Showing content with the highest reputation on 08/21/2021 in all areas
-
Version v3.3.3
11,570 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 -
Screen scraping
SkysLastChance reacted to Nine for a topic
Screen scraping means a way to read / write on the representation of the current screen. You can, with this UDF, read the actual foreground of the screen or a background window. Hidden or minimized window are not supported. I tried to optimize the use of AutoIt as much as I could, but some actions require the performance of a DLL. I have found multiple threads and others UDF discussing this subject but never found an optimized approach to this issue without gathering everything inside a large DLL. The examples I am providing show how to use a background window (even if it is in the foreground when you run it directly with Scite) or use the current screen. Reading current screen is faster (about 20-30 ms faster) than reading a background window. You need to first initialize the structure based on width and height. You can reuse the structure as long as you want if the dimensions do not change. You will need to make a new initialize if dimensions are changing. You do not need (this way) to have the actual size of a window. You can decide to reduce the dimensions to increase performance. Supports x86 and x64. The following functions are included in the UDF : _GetScreen_Initialize($iWidth, $iHeight) _GetScreen_GetScreen() _GetScreen_GetWindow($hWnd, $iFlag = 0) _GetScreen_GetPixel($iX, $iY) _GetScreen_SetPixel($iX, $iY, $iValue) _GetScreen_SearchArea($iLeft, $iTop, $iRight, $iBottom, $iColor, $iStart = 1) _GetScreen_SearchAll($iColor, $iStart = 1) _GetScreen_PixelReplaceArea($iColorFrom, $iColorTo, $iLeft, $iTop, $iRight, $iBottom) _GetScreen_PixelReplaceAll($iColorFrom, $iColorTo) _GetScreen_CheckSumArea($iLeft, $iTop, $iRight, $iBottom) _GetScreen_SaveFile($sFileName) _GetScreen_GetBitMap() Version 2022-04-17 * Added new optional parameter $iFlag to _GetScreen_GetWindow 0 = full window for Win 7 and over 1 = client area for Win 7 and over 2 = full window for Win 10 and over (this can be used with applications (like Chrome) that do not support WM_PRINT or WM_PRINTCLIENT messages) Version 2021-11-28 * Corrected a bug in SearchArea Version 2021-08-30 * Fixed bugs related to areas * Added support to repetitive searches in the same area * Added a function to make a CheckSum of an area * Added an additional example Version 2021-08-24 * Removed unused structure * Harmonized code Example 1 : show various functions using the _GetScreen_GetWindow (background support) Example 2 : show new functions using _GetScreen_GetScreen() (foreground only but faster) All comments are very much welcome. GetScreen.zip1 point -
zPlayer - My own little audio/video player
CYCho reacted to carlvanwormer for a topic
I found that I could make it work if I changed my folder structure to remove spaces. I set out to "fix" the problem by changing the line: $fh = FileOpen(@ScriptDir & "\VLC-Playlist.xspf", 2) to $newstring = '"' & @ScriptDir & "\VLC-Playlist.xspf" & '"' $fh = FileOpen($newstring, 2) ConsoleWrite (" $newstring is " ) ConsoleWrite ($newstring) ConsoleWrite (" $newstring" ) when I run this code I still get the same error results, and the console window shows the quoted string as sent to the system: $newstring is "C:\Users\Carl\Documents\AutoIt\Monk Season 1\VLC-Playlist.xspf" $newstring When I copy this quoted string to the windows console (with or without quotes), it runs the video file. I've attached the playlists from the working (no spaces) and non-working (spaces) runs (removed spaces from folder path). It looks like the VLC program doesn't cope with spaces very well. I can solve the problem by making my directory structure (and probably my filenames) without any spaces. Aside from that problem, your VLC implementation works well. I cannot fully express my gratitude for the help you have given me. I will try to pay it forward. Thanks! Carl VLC-Playlist.xspf VLC-Playlist.xspf1 point -
Here is just some usefull script analyzer: #include <ColorConstants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <StaticConstants.au3> #include <TreeViewConstants.au3> #include <WindowsConstants.au3> #include <File.au3> #include <Array.au3> ; just put a FileFullPath to one of your project _UsedInclude_API() _GetAllDependencies("c:\Program Files (x86)\AutoIt3\SciTE\SciTE Jump\SciTE Jump.au3") _UsedInclude_API() _GetAllDependencies("c:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3") _UsedInclude_API() _GetAllDependencies("c:\Program Files (x86)\AutoIt3\SciTE\SciTEConfig\SciteConfig.au3" ) _UsedInclude_API() _GetAllDependencies(@ScriptFullPath) Func _GetAllDependencies($sFileToCheck) GUICreate("My GUI with treeview", 500, @DesktopHeight - 40) Local $idTreeview = GUICtrlCreateTreeView(6, 6, 488, @DesktopHeight - 40 - 12, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS), $WS_EX_CLIENTEDGE) Local $idDisplayitem = GUICtrlCreateTreeViewItem($sFileToCheck, $idTreeview) GUICtrlSetColor(-1, $COLOR_GREEN) __UsedIncludeToTreeView($sFileToCheck, $idDisplayitem) Local $hItem = GUICtrlGetHandle($idDisplayitem) GUICtrlSendMsg($idTreeview, $TVM_EXPAND, $TVE_TOGGLE, $hItem) GUISetState(@SW_SHOW) Local $idMsg ; Loop until the user exits. While 1 $idMsg = GUIGetMsg() Select Case $idMsg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd EndFunc ;==>_GetAllDependencies Func _GetUsedIncludeToArray($sAU3Content) Local $aIncludes = StringRegExp($sAU3Content, '(?im)^\s*#include\s?[''""<](.*)\.au3[''"">]', 3) If @error Then Return SetError(@error, @extended, '') Else Return SetError(0, 0, $aIncludes) EndIf EndFunc ;==>_GetUsedIncludeToArray Func __UsedIncludeToTreeView($sFileToCheck, $idTreeview_ref) $hFile = FileOpen($sFileToCheck, $FO_READ) $sAU3Content = FileRead($hFile) FileClose($hFile) Local $aIncludes = _GetUsedIncludeToArray($sAU3Content) If @error Then Return SetError(@error, @extended, '') Else Local $idDisplayitem, $iNumberOfOccurrences = 0 For $iInclude_Idx = 0 To UBound($aIncludes) - 1 $iNumberOfOccurrences = _UsedInclude_API($aIncludes[$iInclude_Idx]) If $iNumberOfOccurrences = 0 Then $idDisplayitem = GUICtrlCreateTreeViewItem($aIncludes[$iInclude_Idx], $idTreeview_ref) __UsedIncludeToTreeView(_GetDir($sFileToCheck) & $aIncludes[$iInclude_Idx] & '.au3', $idDisplayitem) ElseIf $iNumberOfOccurrences = 1 Then $idDisplayitem = GUICtrlCreateTreeViewItem($aIncludes[$iInclude_Idx] & ' (Was used before: once)', $idTreeview_ref) GUICtrlSetColor(-1, $COLOR_RED) ElseIf $iNumberOfOccurrences = 2 Then $idDisplayitem = GUICtrlCreateTreeViewItem($aIncludes[$iInclude_Idx] & ' (Was used before: twice)', $idTreeview_ref) GUICtrlSetColor(-1, $COLOR_PURPLE) ElseIf $iNumberOfOccurrences > 2 Then $idDisplayitem = GUICtrlCreateTreeViewItem($aIncludes[$iInclude_Idx] & ' (Was used before more then twice)', $idTreeview_ref) GUICtrlSetColor(-1, $COLOR_BLUE) EndIf Next EndIf EndFunc ;==>__UsedIncludeToTreeView Func _UsedInclude_API($sIncludeFileName = Default) Local Static $sIncludeAPI_Static = '|' ; reset If $sIncludeFileName = Default Then $sIncludeAPI_Static = '|' Return EndIf StringReplace($sIncludeAPI_Static, '|' & $sIncludeFileName & '|', '|' & $sIncludeFileName & '|') Local $iNumberOfReplacements = @extended $sIncludeAPI_Static &= $sIncludeFileName & '|' Return SetError(0, 0, $iNumberOfReplacements) EndFunc ;==>_UsedInclude_API Func _GetDir($sFileFullPath) Local $sDrive = "", $sDir = "", $sFileName = "", $sExtension = "" Local $aPathSplit = _PathSplit($sFileFullPath, $sDrive, $sDir, $sFileName, $sExtension) Return $sDrive & $sDir EndFunc ;==>_GetDir Have fun. mLipok1 point
-
newniman, The problem was that you had not correctly set the position of the ListView within the GUI - see line #55 of this amended script: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <File.au3> #include <GuiListView.au3> Global $hGUI, $hListview, $aHit[2] = [-1, -1] ; $aHit contains row & col of marked cell Local $PIPEFILE = "edit-zoom_step_av_value.csv" Local $aRetArray _FileReadToArray($PIPEFILE, $aRetArray, $FRTA_NOCOUNT);, "|") ; As the delimiters are already "!" why bother to split the lines? <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $hGUI = GUICreate("Mark Cell in Listview", 1040, 590) Local $cListview = GUICtrlCreateListView("Zoom Step|F3.4|F4.0|F4.5|F5.0|F5.6|F6.3|F7.1|F8.0", 24, 100, 472, 300, $LVS_REPORT, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT)) $hListview = GUICtrlGetHandle($cListview) GUICtrlSetFont($cListview, 8, 800, 0, "MS Sans Serif") For $x = 0 To UBound($aRetArray, $UBOUND_ROWS) - 1 ; As the "|" are already in place, this is much easier to write! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< GUICtrlCreateListViewItem($aRetArray[$x], $cListview) Next Local $cButton = GUICtrlCreateButton("Value?", 150, 430, 70, 20) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY"); good tutorial @ https://www.autoitscript.com/wiki/Tutorial_GUIRegisterMsg While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton MsgBox(0, "Info", "Cell selected: " & _GUICtrlListView_GetItemText($hListview, $aHit[0], $aHit[1]) & @CR, 0, $hGUI) ;MsgBox(0, "Info", "zoom_step selected: " & $aHit[0] & " --> Aperture column selected: " & $aHit[1], 0, $hGUI) EndSwitch WEnd Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam ; Used by au3check to tell it not to report on "variable not used" when using the parameter "-w 5" - Correct <<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Local $tNMHDR, $hWndFrom, $iCode $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hListview Switch $iCode Case $LVN_ITEMCHANGED Local $tNMLISTVIEW, $iItem, $aInfo $tNMLISTVIEW = DllStructCreate($tagNMLISTVIEW, $lParam) $iItem = DllStructGetData($tNMLISTVIEW, "Item") _GUICtrlListView_SetItemSelected($hListview, $iItem, False) Local $aInfo = GUIGetCursorInfo($hGUI) If $aInfo[2] Then $aInfo = _GUICtrlListView_SubItemHitTest($hListview, $aInfo[0] - 24, $aInfo[1] - 100) ; Upper left position of ListView within GUI - so must match actual position If $aInfo[0] > -1 And $aInfo[1] > -1 And $aInfo[0] = $iItem Then If $aHit[0] > -1 Then _GUICtrlListView_RedrawItems($hListview, $aHit[0], $aHit[0]) If $aHit[0] <> $aInfo[0] Or $aHit[1] <> $aInfo[1] Then $aHit[0] = $aInfo[0] ; Row $aHit[1] = $aInfo[1] ; Col Else $aHit[0] = -1 ; Row $aHit[1] = -1 ; Col EndIf _GUICtrlListView_RedrawItems($hListview, $iItem, $iItem) EndIf EndIf Case $NM_CUSTOMDRAW Local $tNMLVCUSTOMDRAW = DllStructCreate($tagNMLVCUSTOMDRAW, $lParam) Local $dwDrawStage = DllStructGetData($tNMLVCUSTOMDRAW, "dwDrawStage") Switch $dwDrawStage ; Holds a value that specifies the drawing stage Case $CDDS_PREPAINT ; Before the paint cycle begins Return $CDRF_NOTIFYITEMDRAW ; Notify the parent window of any ITEM-related drawing operations Case $CDDS_ITEMPREPAINT ; Before painting an item Return $CDRF_NOTIFYSUBITEMDRAW ; Notify the parent window of any SUBITEM-related drawing operations Case BitOR($CDDS_ITEMPREPAINT, $CDDS_SUBITEM) ; Before painting a subitem Local $dwItemSpec = DllStructGetData($tNMLVCUSTOMDRAW, "dwItemSpec") ; Item index Local $iSubItem = DllStructGetData($tNMLVCUSTOMDRAW, "iSubItem") ; Subitem index Local $uItemState = DllStructGetData($tNMLVCUSTOMDRAW, "uItemState") ; Item state If $dwItemSpec = $aHit[0] Then ; Marked row Switch $iSubItem Case $aHit[1] ; Marked column DllStructSetData($tNMLVCUSTOMDRAW, "ClrText", 0xFFFFFF) ; Forecolor white DllStructSetData($tNMLVCUSTOMDRAW, "clrTextBk", 0xCC6600) ; Backcolor dark blue, BGR Case Else ; Other columns DllStructSetData($tNMLVCUSTOMDRAW, "ClrText", 0x000000) ; Forecolor black DllStructSetData($tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF) ; Backcolor white EndSwitch Else ; Other rows DllStructSetData($tNMLVCUSTOMDRAW, "ClrText", 0x000000) DllStructSetData($tNMLVCUSTOMDRAW, "ClrTextBk", 0xFFFFFF) EndIf Return $CDRF_NEWFONT ; $CDRF_NEWFONT must be returned after changing font or colors EndSwitch EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY I also removed most of the include files (which were not all necessary) and cleaned up the _FileReadToArray code which makes creating the ListView items much easier. M231 point