Jump to content

Image Search UDF: changes the cursor to an arrow and get's stuck


Recommended Posts

I'm using

 

And I have the following function

Func FindImage($sImagePath, $iAttempts)

    _ImageSearch_Create_BMP($sImagePath)

    For $i = 1 To $iAttempts
        Sleep(1000)
        Local $rImageSearchPos = _ImageSearch($sImagePath)

        If $rImageSearchPos[0] = 1 Then
            Return True
        EndIf
    Next

    Return False
EndFunc

But it changes the cursor to an arrow and stays there waiting.

When I click anywhere it progresses and finds the image.

I didn't want to click. I was expecting him to work unattended.

Thanks!

Link to comment
Share on other sites

The_ImageSearch_Create_BMP() function is only used to quickly create an image file for searching instead of using Paint to cut and save as a file!

EG: 

;~ Opt("MustDeclareVars", 1)
;~ #AutoIt3Wrapper_UseX64=y
;~ #AutoIt3Wrapper_Change2CUI=y
#RequireAdmin

#include "_ImageSearch_UDF.au3"

HotKeySet("{Esc}", "_Exit") ; Press ESC for exit
Func _Exit()
    Exit 0
EndFunc   ;==>_Exit

Global Const $Ask_On_Found = 0
Global Const $Mouse_Move_On_Found = 1
Global Const $Mouse_Click_On_Found = 0
Global Const $iSleep_Time=500

Global $_Image_1 = @ScriptDir & "\example.bmp" ; Your Image to search 

ConsoleWrite("! Search for images: " & $_Image_1 & @CRLF & '! Searching on the screen ...' & @CRLF)

Global $sCount = 0
While 1
    ToolTip('(Press ESC for EXIT) Searching ...', 1, 1)
    Sleep($iSleep_Time)
    $sCount += 1
    Local $return = _ImageSearch($_Image_1)
    If $return[0] = 1 Then
        ConsoleWrite('- [' & $sCount & '] Image found:' & " X=" & $return[1] & " Y=" & $return[2] & @CRLF)
        If $Mouse_Move_On_Found Then
            MouseMove($return[1], $return[2])
            Sleep($iSleep_Time)
        EndIf
        If $Mouse_Click_On_Found Then MouseClick("left", $return[1], $return[2])
        ToolTip('(Press ESC for EXIT) - [' & $sCount & "] Image found:" &  " X=" & $return[1] & " Y=" & $return[2], 1, 1)
        If $Ask_On_Found Then
            Local $ask = MsgBox(6 + 262144, 'Success [' & $sCount & ']', 'Image found:' & " X=" & $return[1] & " Y=" & $return[2])
            If $ask = 2 Or $ask = 3 Or $ask = 5 Or $ask = 7 Then Exit ;No, Abort, Cancel, and Ignore
            If $ask = 10 Then _ImageSearch_Create_BMP($_Image_1) ; Continue       ;Try Again
        EndIf
    EndIf
    Sleep(200)
WEnd

 

Regards,
 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...