Jump to content

Probleme with ImageSearch


YuChan
 Share

Recommended Posts

Hello all,

I have this code :

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

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

Global $_Image_1 = @ScriptDir & "\test.png"

; First, use this function to create a file bmp, maybe a desktop icon for example')
MsgBox(64 + 262144, 'ImageSearch', 'At first, create a file bmp,' & @CRLF & 'photos that will search on the screen!')

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

While 1
    ToolTip('(Press ESC for EXIT) Searching ...', 1, 1)
    Local $return = _ImageSearch($_Image_1)
    If $return[0] = 1 Then
        ConsoleWrite('- Image found:' & " X=" & $return[1] & " Y=" & $return[2] & @CRLF)
        If $Mouse_Move_On_Found Then MouseMove($return[1], $return[2])
        If $Mouse_Click_On_Found Then MouseClick("left", $return[1], $return[2])
        ToolTip('(Press ESC for EXIT) Image found:' & " X=" & $return[1] & " Y=" & $return[2], 1, 1)
        If $Ask_On_Found Then
            Local $ask = MsgBox(6 + 262144, 'Success', '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

My image text.png is one png and can change backround.

How to found my picture.test.bmp

Thank you

Link to comment
Share on other sites

On 1/27/2021 at 3:26 AM, YuChan said:

How to found my picture.

How can you expect an answer, when essential parts of your script are missing ?

"... (19,43) : error: _ImageSearch(): undefined function.
"... (28,64) : error: _ImageSearch_Create_BMP(): undefined function.

Considering your previous posts (many were closed or showed little self-initiative), only a few users will probably bother to help you. That is especially the case, when the sensitive topic of 'imagesearch' comes into play.

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

  • 2 weeks later...

Hello,

Im searching since 2 week and i not found how to make.

 

I have this :

Func _ImageSearch($findImage,$resultPosition, ByRef $x, ByRef $y,$tolerance=255, $HBMP=0)
   return _ImageSearchArea($findImage,$resultPosition,0,0,@DesktopWidth,@DesktopHeight,$x,$y,$tolerance,$HBMP)
EndFunc

 

#include "ImageSearch2015.au3"
#include <GDIPlus.au3>

$fileA = "test.png"
_GDIPlus_Startup()

$hImageA = _GDIPlus_ImageLoadFromFile($fileA)
$hBitmapA = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageA)

$x = 0
$y = 0

$result = _ImageSearch($hBitmapA, 1, $x, $y, 20, 0)

If $result > 0 Then
    MsgBox($MB_SYSTEMMODAL, "Test", "Color was found", 1)
EndIf
 
 
Func idle()
    While 1 
        Switch GUIGetMsg()  
            Case $GUI_EVENT_CLOSE
                exit                
        EndSwitch   
        sleep(40)           
    WEnd
EndFunc

 

Please how to make for srearch one picture with one  for who go test 1 to 255 tolerance ?

My pictures is one png who is tranparent and can change background

THX

test.png

Edited by YuChan
ADD IMAGE FILE
Link to comment
Share on other sites

@junkew : Just a friendly note in case you missed the other threads by @YuChan . Take a look at :

https://www.autoitscript.com/forum/topic/205094-one-gui-who-follow-mouse/?do=findComment&comment=1474709

https://www.autoitscript.com/forum/topic/205096-mouse-position/?do=reportComment&comment=1474661

You're probably wasting your precious time to a person, who doesn't deserve it ;).

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

  • Jos locked this topic
Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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