Jump to content

Recommended Posts

Posted (edited)

Hi;

I've recently had cause to return to using the ImageSearch UDF after a long hiatus and no, I'm not automating gaming scenarios. 

I've read a number of posts and sites discussing the proper use of the ImageSearch function.

Here's what I've done so far to try and figure this out:

  1. Reviewed a number of web postings (these forums & elsewhere) and YT videos.
  2. One of the many sites/sources I've reviewed pointed me to a post from @guestscripter here. From that post, I acquired the ImageSearch2015.zip package.
  3. I unzipped the ImageSearch2015.zip package into it's own folder which then contained:
    • ImageSearch2015.au3
    • ImageSeachDLLx64.dll
    • ImageSearchDLLx86.dll
    • msvcr110.dll
    • msvcr110d.dll
  4. I followed the instructions (which were corroborated on at least three different sites/sources) for using the ImageSearch UDF that explained how to:
    • Add the #RequireAdmin line and run the ImageSearch2105.au3 UDF script then remove the #RequireAdmin.
    • Changed the test flag to false.
    • Removed the Exit from the test function.
  5. I then copied one of the many similar examples for using the UDF and saved the newly created script into the same directory as where the files were unzipped.
  6. Created a screen-capture of a small region on my desktop and saved it as sampleimage.jpg in the same folder as the unzipped files and my new script.

This is the testing script I sourced from multiple examples:

#AutoIt3Wrapper_UseX64=y ; Set to Y or N depending on your situation/preference!!
#include "ImageSearch2015.au3"

$x = 0
$y = 0
$picture = "D:\AutoIt\dog.jpg"
$result = True

$result = _ImageSearch($picture, 0, $x, $y, 0)

MsgBox(0, "Result", "Result = " & $result & @CRLF)
ConsoleWrite("Result = " & $result & @CRLF)
ConsoleWrite("The End" & @CRLF & @CRLF)

After doing that, the result was always a false/fail/0 when running the script. I tried a number of different images and settings when calling the UDF (transparency, tolerance). During these initial trials, I'm not getting any Inconsistent or incompatible Script/Windows/CPU Architecture errors, no DllOpen failure warnings, no Image File not found errors or anything else to indicate that there is a problem (other than the false/0 return result).

I then began drilling down through the ImageSeach2015.au3 UDF and can see where:

  1. The image search function calls the area image search function
  2. The area image search function checks whether it has a handle to the DLL and,
  3. It calls for the DLL to be loaded if it return a -1 from step#2.

As a means to begin following the flow and trying to figure out where things might be failing, I started injecting a number of ConsoleWrite operations into the ImageSeach2015.au3.

Doing this, I got to the point in the ImageSearch2015.au3 where I am displaying the resulting array from the actual DLL call from this line:

$result = DllCall($h_ImageSearchDLL, "str", "ImageSearch", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findImage)

. The _ArrayDisplay values are as follows (the :

  • 0 - $h_ImageSearchDLL  <- Note on this below!
  • 0 - Area to search left coord
  • 0  - Area to search top coord
  • 3840 - Area to search right coord
  • 2160 - Are to search bottom coord
  • D:\AutoIt\Imagesearchtesting\dog.jpg - File of image to find

In the line before the DLLCall, I ConsoleWrite the $h_ImageSearchDLL value and it returns a 1. In the resulting _ArrayDisplay($result) table, the first value is a 0 (zero).

I'm uncertain as to what the 0 because it is 1 before the call and 0 after the call however, I suspect it is indicating the success or failure as to whether the image was found.

The @error value that is returned from the DLL call line is 0 so that indicates that there is no error with the DLL call.

 

This all leads me to believe that there is something not working within the ImageSearchDLLx64.dll or one of the msvcr110.dll files although I have no idea what goes on in those although I could be missing something very basic.

I'm running this within a VCS environment on a Windows 10 Pro OS and I have tried running it by right-clicking the script and selecting "Run script" from the context menu.

Does anyone have any insights that might help me figure this out? I'm really at a standstill.

Thanks in advance!

Edited by jimdaway
  • jimdaway changed the title to UPDATED INFO - ImageSearch issues - Does It Still Work??
  • 3 weeks later...
Posted

Is there any chance someone could provide some insight or direction on this?

I'm still not able to make this work and my research has led me to multiple failures and dead-ends.

 

Posted
Quote

In the line before the DLLCall, I ConsoleWrite the $h_ImageSearchDLL value and it returns a 1. In the resulting _ArrayDisplay($result) table, the first value is a 0 (zero).

The first parameter of DLLCall has to be a filename or file handle. "1" seems not to be a file handle. Where is $h_ImageSearchDLL set?

Rule #1: Always do a backup         Rule #2: Always do a backup (backup of rule #1)

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   1 member

×
×
  • Create New...