Jump to content

Question about using _ImageSearch_Area


Go to solution Solved by VeeDub,

Recommended Posts

Hello,

I am trying to figure out how to use the _ImageSearch_UDF

It sounds like exactly what I need, but I'm finding the examples / notes hard to follow (well actually I think I understand the notes in the UDF, but I'm not getting a match, so I must be stuffing up somewhere).

There have been a few versions of ImageSearch over time, so that there is no confusion, I have attached a copy of the UDF that I'm trying to use.

 I have written a small test script to work out how to use the function _ImageSearch_Area

#RequireAdmin
    Opt("TrayIconDebug",1)

    #include <_ImageSearch_UDF.au3>


    Dim $ImageSearch_Status[2]

    $ImageSearch_Status = _ImageSearch_Area("C:\Temp\desktop_icon.bmp",0,0,80,80)

    ConsoleWrite("ImageSearch_Status: " & $ImageSearch_Status[0] & @CRLF)

The output of the script is as follows:

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Temp\Image_Search.au3" /UserParams    
+>11:00:00 Starting AutoIt3Wrapper (21.316.1639.1) from:SciTE.exe (4.4.6.0)  Keyboard:00000409  OS:WIN_2019/1809  CPU:X64 OS:X64  Environment(Language:0409)  CodePage:0  utf8.auto.check:4
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\ZEN.CYBERX1\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\ZEN.CYBERX1\AppData\Local\AutoIt v3\SciTE 
>Running AU3Check (3.3.16.1)  from:C:\Program Files (x86)\AutoIt3  input:C:\Temp\Image_Search.au3
+>11:00:00 AU3Check ended.rc:0
>Running:(3.3.16.1):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Temp\Image_Search.au3"    
+>Setting Hotkeys...--> Press Ctrl+Alt+Break to Restart or Ctrl+BREAK to Stop.
--\\ ImageSearch by TRONG.LIVE //--  OSArch : X64 // AutoIT ver: 3.3.16.1 x86
-- WorkingDir      : C:\Temp
-- ScriptFullPath  : C:\Temp\Image_Search.au3

+ DllCall: C:\Users\ZEN.CYBERX1\AppData\Local\ImageSearchUDF\ImageSearchDLL_MTXP.dll
! Search not found !
ImageSearch_Status: 0
+>11:00:00 AutoIt3.exe ended.rc:0
+>11:00:00 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 1.113

Basically, it's not finding the designated image.

The image that is in the file: 

C:\Temp\desktop_icon.bmp 

Is the Recycle Bin icon (including the text): Recycle Bin

When I'm running the script, I have SciTE in a window, so that the desktop is partially visible, and in particular the top-left hand corner of the desktop where the Recycle Bin icon is located, is visible.

The arguments: 0,0

Represent the top left corner of the recycle bin icon

And: 80,80

represent the bottom right corner of the recycle bin icon.

So, if I knew what I was doing and was specifying everything correctly, I would expect $ImageSearch_Status[0] to return: 1  (i.e. found / matched)

Rather than what is actually being returned, which is: 0 (i.e. not found)

If someone can tell me at a glance what I'm doing wrong, that would be great!

Otherwise, would appreciate suggestions on things to try / troubleshoot.

Cheers,
VW

_ImageSearch_UDF.au3

Link to comment
Share on other sites

_ImageSearch_Area($_ImagePath, $P_x1 = 0, $P_y1 = 0, $P_x2 = @DesktopWidth, $P_y2 = @DesktopHeight, $_Tolerance = 0, $_CenterPos = True)

If you're not getting the expected results with your image search, it could be due to the images not being exactly the same as those on your desktop. This is where the Tolerance parameter comes into play.

The Tolerance parameter in the _ImageSearch_Area function allows for some degree of inaccuracy in the image matching process. Essentially, a higher Tolerance value means the function can still find a match even if the image isn't a perfect match to the one you're looking for. This can be particularly useful if the image on the screen might change slightly in appearance due to factors like scaling, resolution differences, or minor color variations.

For instance, if you set $_Tolerance to a value greater than 0 (like 10 or 20), the function will tolerate more differences between the searched image and the images on the screen. This could potentially solve the issue if the reason for not finding the image is due to minor discrepancies.

In summary, if your image isn't being found because it's not 100% identical to the one on your desktop, adjusting the Tolerance value might help the _ImageSearch_Area function to find a close, if not exact, match.

but that's just a guess.

Link to comment
Share on other sites

  • Solution

The example is using _ImageSearch rather than _ImageSearch_Area and it does work.

Either there is a problem with _ImageSearch_Area or I'm not calling it correctly.

Either way it looks like I can use _ImageSearch to complete the task.

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...