jimdaway Posted March 5 Posted March 5 (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: Reviewed a number of web postings (these forums & elsewhere) and YT videos. 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. I unzipped the ImageSearch2015.zip package into it's own folder which then contained: ImageSearch2015.au3 ImageSeachDLLx64.dll ImageSearchDLLx86.dll msvcr110.dll msvcr110d.dll 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. 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. 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: The image search function calls the area image search function The area image search function checks whether it has a handle to the DLL and, 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 March 8 by jimdaway
jimdaway Posted Friday at 09:12 AM Author Posted Friday at 09:12 AM 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.
ajag Posted Friday at 09:42 AM Posted Friday at 09:42 AM 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)
KaFu Posted Friday at 09:54 AM Posted Friday at 09:54 AM There's a comment in that thread somewhere at the end that seems to hint that it only works with bmp? OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now