Jump to content
ibrahem

image Search inactive window ,but not minimized.

Recommended Posts

this is a UDF to make image search on inactive window, but not minimized. 

using it, you can seach for coords of an image so that you can use ControlClick to click on it in Background while you are watching a movie or doing something else on the screen.

i am not who made this UDF .

i only fixed some bugs on it :

it wasn't able to run on 64 bit : so i added  #AutoIt3Wrapper_UseX64=NO

it looked for the top left of the image : so i made it find the height \ 2 and the width \ 2  of the image and add them to the Coords so the Coords will be at the middle of the image 

...

here is the UDF :

 

 

imageSearchEX.au3

BmpSearch.au3

 

here is an example :

#AutoIt3Wrapper_UseX64=NO ;because ImageSearchEX doesn't run on 64 bit
#include <imageSearchEX.au3>
$imageSearchEX = imageSearchEX ; this is to make it easy to write the name of the func ^_^

$Win = "..." ;the name or class of requested window
$Image = "..." ;the path to the image you want to look for > it must be 24-bit Bitmap....and remember the more the image is small the faster you find it $_$....
;you can use snipping tool .exe to capture it and use paint .exe to save it as 24-bit Bitmap

$p= $imageSearchEX($Win,$Image)

if $p=0 Then ; what to do if image was not exists
   MsgBox(0,"","Image Doesn't exist")
   EndIf
_ArrayDisplay($p) ; you can delete this line >> as it only shows you the Coords of the image on the window
ControlClick($Win,"leave it blank","the control you want to click","primary ...or the button you want to click","Number of clicks",$p[0],$p[1])

#cs

;If you want to test it on the screen using MouseClick or Mouse move ...etc

$WinSize= WinGetPos("(Frozen) AutoIt v3 Window Info")

MouseMove($p[0] + $WinSize[0],$p[1] + $WinSize[1],1)

#ce

and here are some functions to make it easy to use this UDF :

#AutoIt3Wrapper_UseX64=NO
#include <imageSearchEX.au3>

Global $imageSearchEX = imageSearchEX
Global $FAC = FindAndClick
Global $WUA = WaitUntilAppear
Global $WUATC = WaitUntilAppearThenClick

Func FindAndClick($Window,$Image,$Control)
;~  This function is to find an image that is surely on the window when this function is called
$coords = $imageSearchEX($Window,$Image)
ControlClick($Window,"",$Control,"primary",1,$coords[0],$coords[1])
EndFunc

Func WaitUntilAppear($Window,$Image,$Control)
;~  This function is to pause the script until an image is found on the window
While 1
    $coords = $imageSearchEX($Window,$Image)
    If Not $coords = 0 Then ExitLoop
    Sleep(50)
WEnd
EndFunc

Func WaitUntilAppearThenClick($Window,$Image,$Control)
    ;~  This function is to pause the script until an image is found on the window then click on that image
While 1
    $coords = $imageSearchEX($Window,$Image)
    If Not $coords = 0 Then
        ControlClick($Window,"",$Control,"primary",1,$coords[0],$coords[1])
        ExitLoop
    EndIf
    Sleep(50)
WEnd
EndFunc

 

GAMERS - Asking for help with ANY kind of game automation is against the forum rules. DON'T DO IT.

 

Sorry for bad English 

Edited by ibrahem

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...