Jump to content

1 Screenshot

About This File

Use MouseClick()  mybe must/need:

#RequireAdmin

 

DLL incuded on script!

; #INDEX# =================================================================================================
; Title .........: ImageSearch
; AutoIt Version : 3.x
; Language ......: English
; Description ...: Check image Appears or Not and Return the position of an image on the desktop
; Author(s) .....: Dao Van Trong - TRONG.LIVE
; =================================================================================================

; #CURRENT# =================================================================================================
; _ImageSearch
; _ImageSearch_Area
; _ImageSearch_Wait
; _ImageSearch_WaitArea
; =================================================================================================

;===============================================================================
;
; Author:...........: AutoIT VietNam : Dao Van Trong - TRONG.LIVE
; Description:......: Check image Appears or Not
;                     Find and return the position of an image on the desktop
; Syntax:........... _ImageSearch_Area, _ImageSearch
; Parameter(s):..... $_ImagePath:       The image to locate on the desktop
;                                       May be a list of image by delimited by "|"
;                                       i.e: $_ImagePath = "image1.bmp|image2.bmp|image3.bmp"
; $P_x1 $P_y1:                      Position of 1st point
; $P_x2 $P_y2:                      Position of 2nd point - Default is last botton right of desktop
; $_Tolerance:                      0 for no tolerance (0-255). Needed when colors of image differ from desktop. e.g GIF
;                   $_CenterPos:                        boolen. True will return $array[1] x $array[2] is center of image found.
;                                                           False will return top-left position
; Return Value(s):.. Return an array has 3 item
;                    On Success:                    $array[0] 1
; On Failure:                   $array[0] 0
;                    DLL not found or other error:  $array[0] -1
;                    $array[1] x $array[2]:             position of image what found on desktop
;
; Note:............. Use _ImageSearch to search the entire desktop
;                    _ImageSearch_Area to specify a desktop region to search
;                    $_ImagePath with more item need more time appear on screen before function can detect.
;                    Decrease sleep time in the loop to detect faster. But less performance. I.e CPULoad increased
;
;===============================================================================

EG:

#include "_ImageSearch.au3"
#include "_ImageSearch_Debug.au3"
#RequireAdmin

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 & "\example.bmp"

; 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!')
_ImageSearch_Create_BMP($_Image_1)

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

 

 

Video demo:

 




User Feedback

You may only provide a review once you have downloaded the file.

There are no reviews to display.

  • Similar Content

    • kuhicop
      By kuhicop
      Hello, I need to find an image on screen and return it's position left, top, right, botton.
      I'm using the ImageSearch function but it only returns 1 or 0.
      Any ideas? Thanks!
    • Errious
      By Errious
      Hello,
      maybe i am just tired or i did not understand exactly how to use ImageSearch for different pictures, but i tried now a few things with my example script and only the first part is working.
      Explaining what i try to do, at work we have a programm running which has three different states, they are visible but sometimes the statuses of the process is not running and to avoid a long time without progress of the programm i searched to get a way to have a better visible notification as existing, so there is grey as work in progress, orange for not running and red for aborted, now when the states are changing i would like to receive a little window that is just telling the actual status.
      #include <ImageSearch2015.au3> #include <MsgBoxConstants.au3> #include <AutoItConstants.au3> $x1=0 $y1=0 While 1 sleep(100) $image1 = _ImageSearch("red.png", 1,$x1,$y1,0) If $image1 = 1 then SplashTextOn ( "", "RED !" , 100 , 50 , 1800 , 220 , $DLG_TEXTLEFT, "Arial" , 12 , 500 ) Sleep(1000) SplashOff() sleep(100) EndIf $image2 = _ImageSearch("orange.png", 1,$x1,$y1,0) If $image2 = 1 Then SplashTextOn ( "", "Orange !" , 100 , 50 , 1800 , 220 , $DLG_TEXTLEFT, "Arial" , 12 , 500 ) Sleep(1000) SplashOff() sleep(100) EndIf $image3 = _ImageSearch("grey.png", 1,$x1,$y1,0) If $image3 = 1 Then SplashTextOn ( "", "Grey !" , 100 , 50 , 1800 , 220 , $DLG_TEXTLEFT, "Arial" , 12 , 500 ) Sleep(1000) SplashOff() EndIf WEnd As i said before, part one to receive the state for aborted is working, so i get the splash window for this, but what do i miss for the other two?
      I put the While statement in for continuously running as long it is needed when the program is in use, but i believe i missed something.
    • Nick3399
      By Nick3399
      I have loaded FastFind into my code and it takes a snapshot and creates a BMP file from it. 
      My issue is now I want to imagesearch from that BMP file (or snapshot memory) and look for a specific image from that image and get the coordinates from that. 
      I have looked at all the documentation but I cannot find anything to assist me.
       
      Does anyone have any idea?
    • tiye0405
      By tiye0405
      Hello,
      global $y, $x #RequireAdmin Global $Paused HotKeySet("{NUMPAD2}", "Pause") HotKeySet("{NUMPAD8}", "End") Opt("MouseClickDownDelay", 30) #include <ImageSearch2015.au3> #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <StaticConstants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <UpDownConstants.au3> #include <Misc.au3> Sleep(6000) Sleep(3000) $search1 = _WaitForImageSearch("goo.bmp", 30, 1, $x, $y, 10) If $search1 = 1 Then MouseMove(1500, 1500, 10) Sleep(100) MouseClick("right") Sleep(300) EndIf I've this script.
      The problem is that it work the way it is supposed to but doesnt work on a friends pc, even tho we have the same image search in C/programms(x86)/autoit3/include 
      and the same dll in system 32.
      When he starts the script on the desktop without having the "goo.bmp" file on his pc, the script finds it and right clicks the given location, while for me it doesnt and i have to open the folder with the "goo.bmp" picture in it.

      Im out of ideas on what could cause the problem.
      Any help?
      Thank you in advance
       
       
    • Atoxis
      By Atoxis
      Howdy, I've gone through a lot of au3 forums, and I once had a working Imagesearch script that I got from here.  However, and i'm just totally not sure how but my imagesearch scripts aren't working anymore.
      I'm not new to au3 but i'm not the most experienced with it's syntax/commands.

      Anyways, I've looked over the big threads involving imagesearch.

      Does anyone have a working Imagesearch x64 for win10 that is currently working as of the date with the post.

      Dll's and what not is fine, just when I tell the script to run, I want to be able to find the image on the screen!
      Can't find a working copy so if anyone has one please send it my way lol.

      I've taken all the imagesearch downloads and what not and have played with them but I can't get any of them working on my end, despite others saying they're working.
      Thanks.
×