#include #include _ImageSearch_Startup() If @error Then MsgBox(16, "Error", "ImageSearch DLL could not be initialized. Exiting.") Exit EndIf $formTest = GUICreate("Test Form", 400, 200, 900, 100) ; width, heigh, left, top $lblDesktop = GUICtrlCreateLabel("desktop size", 10, 10, 380, 30) ; left, top, width, height GUICtrlSetFont(-1, 14, 400, 0, "Liberation Sans Narrow") $lblMssg1 = GUICtrlCreateLabel("message 1", 10, 50, 380, 30) GUICtrlSetFont(-1, 14, 400, 0, "Liberation Sans Narrow") $lblMssg2 = GUICtrlCreateLabel("Image search not started", 10, 90, 380, 30) GUICtrlSetFont(-1, 14, 400, 0, "Liberation Sans Narrow") $cmdSearch = GUICtrlCreateButton("Search", 300, 150, 90, 30) GUICtrlSetFont(-1, 14, 400, 0, "Liberation Sans Narrow") GUISetState(@SW_SHOW) $sDeskTop = "Desktop width: " & @DesktopWidth & " height: " & @DesktopHeight ConsoleWrite($sDeskTop & @CRLF) GUICtrlSetData($lblDesktop, $sDeskTop) Func DoSearch() Local $sWrite = "" ; whole & all screens, tolerance=40, give top left, scale 1~5 Local $aResult = _ImageSearch("recycle.png", 0, 0, 0, 0, -1, 40, 1, 0, 1, 5) If $aResult[0][0] > 0 Then ConsoleWrite("Found " & $aResult[0][0] & " match(es)!" & @CRLF) ; Loop through each match ; [0][0] = Match count (0 if not found) ; [1][0] = X coordinate of first match ; [1][1] = Y coordinate of first match ; [1][2] = Width of matched image ; [1][3] = Height of matched image ; [n][0..3] = Additional matches if $iResults > 1 For $i = 1 To $aResult[0][0] Local $iX = $aResult[$i][0] ; X coordinate Local $iY = $aResult[$i][1] ; Y coordinate $sWrite = "Match #" & $i & " found at: " & $iX & ", " & $iY ConsoleWrite($sWrite & @CRLF) GUICtrlSetData($lblMssg2, $sWrite) ;ToolTip($sWrite, 1380, 50) MouseMove($iX, $iY) Sleep(1000) Next Else $sWrite = "Image not found" ConsoleWrite($sWrite & @CRLF) GUICtrlSetData($lblMssg2, $sWrite) EndIf EndFunc While 1 Local $aPos = MouseGetPos() ;ToolTip("x: " & $aPos[0] & ", y: " & $aPos[1], 1380, 50) GUICtrlSetData($lblMssg1, "x: " & $aPos[0] & ", y: " & $aPos[1]) $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ExitLoop Case $cmdSearch DoSearch() EndSwitch WEnd