Jump to content

ImageSearch Usage Explanation


Centrally
 Share

Recommended Posts

I've used this for automating a daily job at work that refreshes +/- 35 reports daily with each one searching, and it hasn't missed a beat.

I'm curious as to the difference in .dll files, compared to the one in the original post from 2008. Here's the two versions:

Original ImageSearchDLL.dll 92k 2/28/2008

Your ImageSearchDLL.dll 77k 1/24/2010

Can you (or anyone else) tell me what the differences are?

Link to comment
Share on other sites

I've used this for automating a daily job at work that refreshes +/- 35 reports daily with each one searching, and it hasn't missed a beat.

I'm curious as to the difference in .dll files, compared to the one in the original post from 2008. Here's the two versions:

Original ImageSearchDLL.dll 92k 2/28/2008

Your ImageSearchDLL.dll 77k 1/24/2010

Can you (or anyone else) tell me what the differences are?

I'm not really sure about difference because I only compiled last source code I found, if you really want to find out what is different than try finding source code from 2008 and compare it to one from 2010.
Link to comment
Share on other sites

  • 3 weeks later...

I was having trouble like you were having trouble. This topic is very helpful.

I was working on this image search for hours and hours and I could not get it to work! I was able to find the droid I was looking for (heh) when I saved the image as a 24-bit BMP rather than 256 or 16-bit. Not sure why this is but I hope that helps someone. If it isn't working for you, try saving the picture as a different bmp file.

Link to comment
Share on other sites

  • 2 weeks later...

Hello and thank you for the tutorial. I have been trying to get this imagesearch function to work for weeks! I took your code and copied it exactly. Then I took ImageSearch.au3, imagesearchdll.dll and my script (Which is a new script file with your code) along with my checkImage.bmp and put them all into my working directory folder. I click the script, I click P and nothing happens but the script no longer runs. I get no error or anything. Did I miss something?

Link to comment
Share on other sites

  • 3 months later...

I added this code in _imageSearchArea

Func _ImageSearchArea($findImage, $resultPosition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $tolerance, $HBMP = 0)
    ;MsgBox(0,"asd","" & $x1 & " " & $y1 & " " & $right & " " & $bottom)
    If $tolerance > 0 Then $findImage = "*" & $tolerance & " " & $findImage
    If IsString($findImage) Then
        $result = DllCall("ImageSearchDLL.dll", "str", "ImageSearch", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findImage, "ptr", $HBMP)
        $err = @error
    Else
        $result = DllCall("ImageSearchDLL.dll", "str", "ImageSearch", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "ptr", $findImage, "ptr", $HBMP)
        $err = @error
    EndIf
    Switch $err
        Case 1
            ConsoleWriteError("unable to use the DLL file" & @CRLF)
            exit 1
        Case 2
            ConsoleWriteError('unknown "return type" ' & @CRLF)
            exit 1
        Case 3
            ConsoleWriteError('"ImageSearch" not found in DLL' & @CRLF)
            exit 1
        Case 4
            ConsoleWriteError('bad number of parameters' & @CRLF)
            exit 1
        Case 5
            ConsoleWriteError('bad parameter' & @CRLF)
            exit 1
    EndSwitch

    ; If error exit
    If $result[0] = "0" Then Return 0

    ; Otherwise get the x,y location of the match and the size of the image to
    ; compute the centre of search
    $array = StringSplit($result[0], "|")

    $x = Int(Number($array[2]))
    $y = Int(Number($array[3]))
    If $resultPosition = 1 Then
        $x = $x + Int(Number($array[4]) / 2)
        $y = $y + Int(Number($array[5]) / 2)
    EndIf
    Return 1
EndFunc   ;==>_ImageSearchArea

I down loaded the 64 bit version, and I get the "unable to use the DLL file" error.

I thought this might help some to debug.

I don't have it working, but I'll try the 32 bit version even though I'm running 64 bit windows 7.

tbodine

Link to comment
Share on other sites

I added code to test that DLL loads and runs and complain if not:

Func _ImageSearchArea($findImage, $resultPosition, $x1, $y1, $right, $bottom, ByRef $x, ByRef $y, $tolerance, $HBMP = 0)
    ;MsgBox(0,"asd","" & $x1 & " " & $y1 & " " & $right & " " & $bottom)
    If $tolerance > 0 Then $findImage = "*" & $tolerance & " " & $findImage
    If IsString($findImage) Then
        $result = DllCall("ImageSearchDLL.dll", "str", "ImageSearch", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "str", $findImage, "ptr", $HBMP)
        $err = @error
    Else
        $result = DllCall("ImageSearchDLL.dll", "str", "ImageSearch", "int", $x1, "int", $y1, "int", $right, "int", $bottom, "ptr", $findImage, "ptr", $HBMP)
        $err = @error
    EndIf
    Switch $err
        Case 1
            ConsoleWriteError("unable to use the DLL file" & @CRLF)
            exit 1
        Case 2
            ConsoleWriteError('unknown "return type" ' & @CRLF)
            exit 1
        Case 3
            ConsoleWriteError('"ImageSearch" not found in DLL' & @CRLF)
            exit 1
        Case 4
            ConsoleWriteError('bad number of parameters' & @CRLF)
            exit 1
        Case 5
            ConsoleWriteError('bad parameter' & @CRLF)
            exit 1
    EndSwitch

    ; If error exit
    If $result[0] = "0" Then Return 0

    ; Otherwise get the x,y location of the match and the size of the image to
    ; compute the centre of search
    $array = StringSplit($result[0], "|")

    $x = Int(Number($array[2]))
    $y = Int(Number($array[3]))
    If $resultPosition = 1 Then
        $x = $x + Int(Number($array[4]) / 2)
        $y = $y + Int(Number($array[5]) / 2)
    EndIf
    Return 1
EndFunc   ;==>_ImageSearchArea

Using this I found that on my computer at work the 64 bit version of the DLL gives the error unable to use the DLL file

The 32 bit version when used causes AutoIT to stop working.

Bummer I sure did like this thing back in the old XP days.

Regards tbodine88

tbodine

Link to comment
Share on other sites

Run the script as a 32 bit exe

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

  • 2 weeks later...

Hello, i tried this plugin and it work very well, but i cant understand one thing: if the image is in a folder located in the script folder, what is the code to make it look inside another folder instead of his own one? My english is bad, if you dont understand, i can try to reformulate the sentence xD

Link to comment
Share on other sites

  • 3 months later...

Just a  small concern of mine about this whole deal:

If, in order to use these functions, I am forced to use a DLL that I do not understand - what happens if in the future the DLL would need to be changed in order to work but no one knows how to change it? do all my scripts stop working forever?

Link to comment
Share on other sites

  • 3 months later...
  • 1 month later...

The right side and bottom corner of the rectangle you want to search in.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

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

×
×
  • Create New...