Jump to content

BmpSearch - Search for Bitmap within Bitmap - Assembly Version


Beege
 Share

Recommended Posts

Oh how could I forget this.. Ya its confusing. I think* that had something to do with how window size/position is not exact when using the $WS_POPUPWINDOW. If you notice in the example, I create the GUI being size 40x10. The first call to WinGetPos reports back the window size as 42x12, then the bitmap is found being 43x13 :blink:.. I dont know what to say about all that. I want to say the boarder is not counted for or something but not certian

Link to comment
Share on other sites

  • 1 month later...
On 30.10.2018 at 7:35 AM, Beege said:

Yes that should be possible. At one point in time I was making a capture tool that could be used to capture a small pic like your describing, and then encode the bmp into a string and wrap it up into a function that you could call for just for simply that - look for this picture and click here within that pic. I have not tried this on windows 10 yet but give this a shot and see if you have any luck getting it to generate. If works it will generate a function that has the picture of the icon you captured and will move the mouse to that location. I have the code to click the button commented out for testing. 

Edit: a little about how the tool works - after you capture an image, it will show you the image back zoomed in. This is so you can capture where you want the mouse to go. So capture one is the image you are looking for - capture 2 is where you want to click within that image. The idea here was to help in situations where you have multiple buttons on the screen that look the same. This way I can more easily say for example - find this picture, but click the top left corner. 

BmpSearch_with_Capture.zip

Hey.
Thank you so much for your hard work! It's great.

I have questions on the theory of this script.

Tell me please. Steps:
1. I run the script.
2. I select the necessary "button"
3. An enlarged image pops up.
4. I highlight the center of the image?
5. Does the script generate coded bmp?
6. I copy the encoded bmp. I sign it that this is my button.
7. And I do some coded bmp, as there are a lot of buttons.
8. How to click? "I have the button commented out for testing."

 

I'm trying to make a click on the button, having a button template (bmp)


Thanks in advance for the answers. I apologize for the English. I am writing from a translator.

Link to comment
Share on other sites

#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <ScreenCapture.au3>
#include <ClipBoard.au3>
#include <ColorConstants.au3>
#include <GDIPlus.au3>
#include <file.au3>

#include "QuickLZ.au3"
#include "_CrossHairs.au3"
#include "BmpSearch.au3"
;~ #include "fasmex.au3"
Func _ClickPic_0()

    Local $aMouse[2] = [18, 15]

    ;####### (BinaryStrLen = 8510) #### (CompStrLen = 1236) #### (Base64StrLen = 824 ) #####################################################################
    Local $bBMP = 'AktoAgAAnhAAAIAqhvFCTZ4QAAAABAA2BAAoFAAjBAABABgEABMAxA4AAGjYGwD39vVgdP9gdP9gdHWIwACCn5nWYHQ2npnUYXQ5ZV3CEAC9JEtgdDBlXb8PALZlXb5gdDNlXcMRAIABDJzOEgDlEQDNIUstJOYQAMURANoQAMQg9zDkjBAAvhIA5kyEoD0rLebGEXQB4IcA2yxp2uTXwK4wLFrPQIQtZV3AEADHEQDdEQDcJGkElyTmY3Q4wFgoLmnIEQDe4QB6kCwP3RAAxiPmNnB0IVonZV3BEQDJEQDfLDzeBLUg5jxhdCcteMoSAOASKOzfEHzoEZ4AyCRpYHQzYHQSIVobLXjLEgDhTPPgJFshaUhhdBs7eOISAGVd4REAyiR4Y3RFYHQMIVoSEQAQRr+HzBIA40zR4hEAyyF4VGF0FRIA5Eym4yB5XWB0GCQOInhafnQ4WudAhDNjdAxjdC0sWtASAOgMIBzCEgDEXcBdZ2VdxBEA0RIA6Uxq6BEAzyU9Q4RgLS3SEgDqTEjpEQDQJFoPPYDxIFoSIUszYHQbLS3TEgDrTFnqJMMkWnB0IFpaZV3GEgDUEwDsZC5EWREA0iUtYHQMIFpUAXE9kC4P1RMA7hMA7WQuEQDTIC0PYnRUOw/vbAzuRJYhLRVgdE4sD9YTAPATAMV87xI8gL74ANUkD2N0DGJ0EiBaQp+Z2REAxhMA8Wzy8ECHJGB0FQRv4IwwLA/XZOMSANYiDyFidAw8WiQs/38AgCNLNiQPJKQgDy18dARcJFpjdBJjdCfkc2N0NuCMOWN0OWJ0/2J0jPX39vU=' & @CRLF


    $bBMP = _QuickLZ_Decompress(_Base64Decode_MS($bBMP))

    Local $hFind = _GDIPlus_BitmapCreateFromMemory($bBMP, True)
    Local $hSource = _ScreenCapture_Capture('', 0, 0, -1, -1, False)
    Local $aCords = _BmpSearch($hSource, $hFind)
    If @error Then Return SetError(@error, ConsoleWrite('Error : Unable to find image' & @LF), 0)

    _WinAPI_DeleteObject($hSource)
    _WinAPI_DeleteObject($hFind)

    MouseMove($aCords[1][2] + $aMouse[0], $aCords[1][3] + $aMouse[1])
    MouseClick($aCords[1][2] + $aMouse[0], $aCords[1][3] + $aMouse[1])

EndFunc

I run such a script. But nothing happens. No error, no click. What am I doing wrong?

Link to comment
Share on other sites

On 30.10.2018 at 7:35 AM, Beege said:

Yes that should be possible. At one point in time I was making a capture tool that could be used to capture a small pic like your describing, and then encode the bmp into a string and wrap it up into a function that you could call for just for simply that - look for this picture and click here within that pic. I have not tried this on windows 10 yet but give this a shot and see if you have any luck getting it to generate. If works it will generate a function that has the picture of the icon you captured and will move the mouse to that location. I have the code to click the button commented out for testing. 

Edit: a little about how the tool works - after you capture an image, it will show you the image back zoomed in. This is so you can capture where you want the mouse to go. So capture one is the image you are looking for - capture 2 is where you want to click within that image. The idea here was to help in situations where you have multiple buttons on the screen that look the same. This way I can more easily say for example - find this picture, but click the top left corner. 

BmpSearch_with_Capture.zip

What files need to register at the beginning of the script?

#include
Link to comment
Share on other sites

#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <ScreenCapture.au3>
#include <ClipBoard.au3>
#include <ColorConstants.au3>
#include <GDIPlus.au3>
#include <file.au3>
#include "QuickLZ.au3"
#include "BmpSearch.au3"

_ClickPic_0()
Func _ClickPic_0() 

    Local $aMouse[2] = [20, 18]

    ;####### (BinaryStrLen = 10934) #### (CompStrLen = 1474) #### (Base64StrLen = 984 ) #####################################################################
    Local $bBMP = 'AkvfAgAAWhUAAICqGMZCTVoVAAAABAA2BAAoBAArBAApBAABABgEABAAxA4AAGjYGAD39vVgdH7/MQaGBABgdP9wdAMA/3x0AAD/YHT/YnQSAAAkn5nWYnQSY3QknpnUYHQkAAAhZV3CEAC9JEtjdDBlXb8PYAAYwAC2ZV2+YHQhAAAeZV3DEQDOEgDlEQDNIUstJOYQAMURANoQAMQg9yEDhy6AAAAb5IwQAL4SAOZMhKA9Ky3mxhEA2yxp2uTXwK4eAAAjz0CELWVdwBAAxxEA3fiH8IMRANwkaQSXJOZgdB4DACNkOcBYKC5pyBEA3iwP3RAAxiPmIWR0AwAhZHQsWsBYImVdwREA0Afhj8kRAN8sPN4EtSDmJGF0J2J0JC14yhIA4BIo7N8QAMgkaWR0YXQkAAAkcXQhWhsteMsSAPojfKDhTPPgJFshaSpkdAEAKmR0IVoVO3jiEgBlXeERAMokeGJ0JH50AgAtYXQVEQDMEgDjTNHiePT3wBEAyyF4MGR0AwAwYHQSEgDkTKbjIHk2YXQ2YnQVJA4ieDNkdGN0QedAhDNxdGN0DAAAONASAOgSAMRdA8IJ4cBdQwMAMsQRANESAOlMaugRAM8lPUOEPwAALWVdhDnSEgDqTEjpEQDQJFohWicPfQDjY3QSfHQAACotLdMSAOtMWeokwyRacHQhWj8AACdlXcYSANQTAOxkLkRZEQDSJS1gdAwHxOuDIVo8AAAkLg/VEwDuEwDtZC4RANMjLQ9jdD8AACE7D+9sDO5EliAtFWF0PAAAHiwP1hMA8BPCB9CXAMV87xIA1SQPYHQMY3QSIFozAAAbn5nZEQDGEwDxbPLwQIckYXQVBG/gjB4AACPXZOMSAP7//4fWIg8hYHQMPFokLCFLIQMAJCSkIw8tfXQEXCRaYHQSYHQPAwAhZHTkc2B0IWB0FeCMJwAAJGN0NmF0KgEA/3x0AQD/Y3SM9QAAAA==' & @CRLF


    $bBMP = _QuickLZ_Decompress(_Base64Decode_MS($bBMP))

    Local $hFind = _GDIPlus_BitmapCreateFromMemory($bBMP, True)
    Local $hSource = _ScreenCapture_Capture('', 0, 0, -1, -1, False)
    Local $aCords = _BmpSearch($hSource, $hFind)
    If @error Then Return SetError(@error, ConsoleWrite('Error : Unable to find image' & @LF), 0)

    _WinAPI_DeleteObject($hSource)
    _WinAPI_DeleteObject($hFind)

    MouseMove($aCords[1][2] + $aMouse[0], $aCords[1][3] + $aMouse[1])
    MouseClick($aCords[1][2] + $aMouse[0], $aCords[1][3] + $aMouse[1])

EndFunc

Func _Base64Decode_MS($input_string)
    Local $tInput = DllStructCreate('char[' & StringLen($input_string) + 1 & ']')
    DllStructSetData($tInput, 1, $input_string & 0)
    Local $aSize = DllCall("Crypt32.dll", "bool", "CryptStringToBinary", "struct*", $tInput, "dword", 0, "dword", 1, "ptr", 0, "dword*", 0, "ptr", 0, "ptr", 0)
    Local $tDecoded = DllStructCreate("byte[" & $aSize[5] & "]")
    Local $aDecode = DllCall("Crypt32.dll", "bool", "CryptStringToBinary", "struct*", $tInput, "dword", 0, "dword", 1, "struct*", $tDecoded, "dword*", $aSize[5], "ptr", 0, "ptr", 0)
    If Not $aDecode[0] Or @error Then Return SetError(1, 0, 0)
    Return DllStructGetData($tDecoded, 1)
EndFunc   ;==>_Base64Decode_MS

Somebody, show 1 working example. Beg. Thank!

Link to comment
Share on other sites

15 hours ago, Kolokol1 said:

Tell me please. Steps:
1. I run the script. 
2. I select the necessary "button" - Yes here you capture the button your searching for. What you select will be the bmp and gets saved as base64 string in the function that gets generated.
3. An enlarged image pops up. - Yes. I have the image you captured in step 2 enlarged so it makes it easier to select a location to click
4. I highlight the center of the image? - You select the location that you would want the mouse click to happen at. The button may be in the corner of the image you selected so you can make the click happen at a specific spot in the image your searching for.
5. Does the script generate coded bmp? - Yes see step 2
6. I copy the encoded bmp. I sign it that this is my button. Not sure what you mean here. At this point you should get a message box that function is on clipboard. From here you paste the function in your script and test. 
7. And I do some coded bmp, as there are a lot of buttons.
8. How to click? "I have the button commented out for testing." -  Uncomment mouseclick command to perform click. Use mousemove command for testing that its going to click the loction you plan too. If the mousemove to a spot your not expecting somethings not right. If it lands on the correct spot, comment out the mousemove command and enable mouseclick. 

 

11 hours ago, Kolokol1 said:

Somebody, show 1 working example. Beg. Thank!

lol nobody can make this work but you because these are images on YOUR screen ;) You got the function generated so your close. When you run the code does it find the image and move the mouse or print to the console that it couldnt find the image?

EDIT: Why does your $bBMP have "& @CRLF" on the end of it? Thats not correct

Edited by Beege
Link to comment
Share on other sites

On 15.12.2018 at 2:55 AM, Beege said:

 

lol nobody can make this work but you because these are images on YOUR screen ;) You got the function generated so your close. When you run the code does it find the image and move the mouse or print to the console that it couldnt find the image?

EDIT: Why does your $bBMP have "& @CRLF" on the end of it? Thats not correct

#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <ScreenCapture.au3>
#include <ClipBoard.au3>
#include <ColorConstants.au3>
#include <GDIPlus.au3>
#include <file.au3>

#include "QuickLZ.au3"
#include "BmpSearch.au3"
#include "_CrossHairs.au3"


_ClickPic_0()
Func _ClickPic_0() 

    Local $aMouse[2] = [20, 18]

    ;####### (BinaryStrLen = 10934) #### (CompStrLen = 1474) #### (Base64StrLen = 984 ) #####################################################################
    Local $bBMP = 'AkvfAgAAWhUAAICqGMZCTVoVAAAABAA2BAAoBAArBAApBAABABgEABAAxA4AAGjYGAD39vVgdH7/MQaGBABgdP9wdAMA/3x0AAD/YHT/YnQSAAAkn5nWYnQSY3QknpnUYHQkAAAhZV3CEAC9JEtjdDBlXb8PYAAYwAC2ZV2+YHQhAAAeZV3DEQDOEgDlEQDNIUstJOYQAMURANoQAMQg9yEDhy6AAAAb5IwQAL4SAOZMhKA9Ky3mxhEA2yxp2uTXwK4eAAAjz0CELWVdwBAAxxEA3fiH8IMRANwkaQSXJOZgdB4DACNkOcBYKC5pyBEA3iwP3RAAxiPmIWR0AwAhZHQsWsBYImVdwREA0Afhj8kRAN8sPN4EtSDmJGF0J2J0JC14yhIA4BIo7N8QAMgkaWR0YXQkAAAkcXQhWhsteMsSAPojfKDhTPPgJFshaSpkdAEAKmR0IVoVO3jiEgBlXeERAMokeGJ0JH50AgAtYXQVEQDMEgDjTNHiePT3wBEAyyF4MGR0AwAwYHQSEgDkTKbjIHk2YXQ2YnQVJA4ieDNkdGN0QedAhDNxdGN0DAAAONASAOgSAMRdA8IJ4cBdQwMAMsQRANESAOlMaugRAM8lPUOEPwAALWVdhDnSEgDqTEjpEQDQJFohWicPfQDjY3QSfHQAACotLdMSAOtMWeokwyRacHQhWj8AACdlXcYSANQTAOxkLkRZEQDSJS1gdAwHxOuDIVo8AAAkLg/VEwDuEwDtZC4RANMjLQ9jdD8AACE7D+9sDO5EliAtFWF0PAAAHiwP1hMA8BPCB9CXAMV87xIA1SQPYHQMY3QSIFozAAAbn5nZEQDGEwDxbPLwQIckYXQVBG/gjB4AACPXZOMSAP7//4fWIg8hYHQMPFokLCFLIQMAJCSkIw8tfXQEXCRaYHQSYHQPAwAhZHTkc2B0IWB0FeCMJwAAJGN0NmF0KgEA/3x0AQD/Y3SM9QAAAA==' 


    $bBMP = _QuickLZ_Decompress(_Base64Decode_MS($bBMP))

    Local $hFind = _GDIPlus_BitmapCreateFromMemory($bBMP, True)
    Local $hSource = _ScreenCapture_Capture('', 0, 0, -1, -1, False)
    Local $aCords = _BmpSearch($hSource, $hFind)
    If @error Then Return SetError(@error, ConsoleWrite('Error : Unable to find image' & @LF), 0)

    _WinAPI_DeleteObject($hSource)
    _WinAPI_DeleteObject($hFind)

    MouseMove($aCords[1][2] + $aMouse[0], $aCords[1][3] + $aMouse[1])
    MouseClick($aCords[1][2] + $aMouse[0], $aCords[1][3] + $aMouse[1])

EndFunc

such code is such an error

image.png.93d738a1daee42c3cafe2d73b5157a90.png

 

 

I see that there is not enough function

 

image.thumb.png.cf3d6a5f4607fa6f94e65cb43e4034c9.png

 

I tried to add a function but in vain.
image.png.480c6bd1333a36bab77cdd04d1c28ff8.png

On 15.12.2018 at 2:55 AM, Beege said:

lol nobody can make this work but you because these are images on YOUR screen

Did I ask to recognize the images on my screen? I requested a working code for an example. Do you understand what working code is? The code that will be with all the functions. What you published does not work out of the box.

 

 

Link to comment
Share on other sites

16 minutes ago, Kolokol1 said:

Did I ask to recognize the images on my screen? I requested a working code for an example. Do you understand what working code is?

No Kolokol1- I do not understand what "working code" example is to you in this situation where my function GENERATES code that captures a specific image on your screen. Do you understand the difference between working code and whatever example your asking for?

Your first error is you didnt have the function in your script. For the second error you posted you have some other error going on in your script if getting incorrect number of parameters error. The function only has one parameter so issue looks to be somewhere else in code not posted

Link to comment
Share on other sites

11 minutes ago, Beege said:

Your first error is you didnt have the function in your script

Func _Base64Decode_MS($input_string)
    Local $tInput = DllStructCreate('char[' & StringLen($input_string) + 1 & ']')
    DllStructSetData($tInput, 1, $input_string & 0)
    Local $aSize = DllCall("Crypt32.dll", "bool", "CryptStringToBinary", "struct*", $tInput, "dword", 0, "dword", 1, "ptr", 0, "dword*", 0, "ptr", 0, "ptr", 0)
    Local $tDecoded = DllStructCreate("byte[" & $aSize[5] & "]")
    Local $aDecode = DllCall("Crypt32.dll", "bool", "CryptStringToBinary", "struct*", $tInput, "dword", 0, "dword", 1, "struct*", $tDecoded, "dword*", $aSize[5], "ptr", 0, "ptr", 0)
    If Not $aDecode[0] Or @error Then Return SetError(1, 0, 0)
    Return DllStructGetData($tDecoded, 1)
EndFunc   ;==>_Base64Decode_MS

How to add a function correctly?

Link to comment
Share on other sites

Issue is not there. Post the full code you are getting an error with

Link to comment
Share on other sites

1 minute ago, Beege said:

Post the full code

1. Im download this BmpSearch_with_Capture.zip

2. I ran the script BmpSearch_with_Capture.au3

3. I pasted the code from the clipboard into the test script:

Func _ClickPic_0() 

    Local $aMouse[2] = [20, 18]

    ;####### (BinaryStrLen = 10934) #### (CompStrLen = 1474) #### (Base64StrLen = 984 ) #####################################################################
    Local $bBMP = 'AkvfAgAAWhUAAICqGMZCTVoVAAAABAA2BAAoBAArBAApBAABABgEABAAxA4AAGjYGAD39vVgdH7/MQaGBABgdP9wdAMA/3x0AAD/YHT/YnQSAAAkn5nWYnQSY3QknpnUYHQkAAAhZV3CEAC9JEtjdDBlXb8PYAAYwAC2ZV2+YHQhAAAeZV3DEQDOEgDlEQDNIUstJOYQAMURANoQAMQg9yEDhy6AAAAb5IwQAL4SAOZMhKA9Ky3mxhEA2yxp2uTXwK4eAAAjz0CELWVdwBAAxxEA3fiH8IMRANwkaQSXJOZgdB4DACNkOcBYKC5pyBEA3iwP3RAAxiPmIWR0AwAhZHQsWsBYImVdwREA0Afhj8kRAN8sPN4EtSDmJGF0J2J0JC14yhIA4BIo7N8QAMgkaWR0YXQkAAAkcXQhWhsteMsSAPojfKDhTPPgJFshaSpkdAEAKmR0IVoVO3jiEgBlXeERAMokeGJ0JH50AgAtYXQVEQDMEgDjTNHiePT3wBEAyyF4MGR0AwAwYHQSEgDkTKbjIHk2YXQ2YnQVJA4ieDNkdGN0QedAhDNxdGN0DAAAONASAOgSAMRdA8IJ4cBdQwMAMsQRANESAOlMaugRAM8lPUOEPwAALWVdhDnSEgDqTEjpEQDQJFohWicPfQDjY3QSfHQAACotLdMSAOtMWeokwyRacHQhWj8AACdlXcYSANQTAOxkLkRZEQDSJS1gdAwHxOuDIVo8AAAkLg/VEwDuEwDtZC4RANMjLQ9jdD8AACE7D+9sDO5EliAtFWF0PAAAHiwP1hMA8BPCB9CXAMV87xIA1SQPYHQMY3QSIFozAAAbn5nZEQDGEwDxbPLwQIckYXQVBG/gjB4AACPXZOMSAP7//4fWIg8hYHQMPFokLCFLIQMAJCSkIw8tfXQEXCRaYHQSYHQPAwAhZHTkc2B0IWB0FeCMJwAAJGN0NmF0KgEA/3x0AQD/Y3SM9QAAAA==' 


    $bBMP = _QuickLZ_Decompress(_Base64Decode_MS($bBMP))

    Local $hFind = _GDIPlus_BitmapCreateFromMemory($bBMP, True)
    Local $hSource = _ScreenCapture_Capture('', 0, 0, -1, -1, False)
    Local $aCords = _BmpSearch($hSource, $hFind)
    If @error Then Return SetError(@error, ConsoleWrite('Error : Unable to find image' & @LF), 0)

    _WinAPI_DeleteObject($hSource)
    _WinAPI_DeleteObject($hFind)

    MouseMove($aCords[1][2] + $aMouse[0], $aCords[1][3] + $aMouse[1])
    MouseClick($aCords[1][2] + $aMouse[0], $aCords[1][3] + $aMouse[1])

EndFunc

 

All code is

#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <ScreenCapture.au3>
#include <ClipBoard.au3>
#include <ColorConstants.au3>
#include <GDIPlus.au3>
#include <file.au3>
#include "QuickLZ.au3"
#include "BmpSearch.au3"

_ClickPic_0()
Func _ClickPic_0() 

    Local $aMouse[2] = [20, 18]

    ;####### (BinaryStrLen = 10934) #### (CompStrLen = 1474) #### (Base64StrLen = 984 ) #####################################################################
    Local $bBMP = 'AkvfAgAAWhUAAICqGMZCTVoVAAAABAA2BAAoBAArBAApBAABABgEABAAxA4AAGjYGAD39vVgdH7/MQaGBABgdP9wdAMA/3x0AAD/YHT/YnQSAAAkn5nWYnQSY3QknpnUYHQkAAAhZV3CEAC9JEtjdDBlXb8PYAAYwAC2ZV2+YHQhAAAeZV3DEQDOEgDlEQDNIUstJOYQAMURANoQAMQg9yEDhy6AAAAb5IwQAL4SAOZMhKA9Ky3mxhEA2yxp2uTXwK4eAAAjz0CELWVdwBAAxxEA3fiH8IMRANwkaQSXJOZgdB4DACNkOcBYKC5pyBEA3iwP3RAAxiPmIWR0AwAhZHQsWsBYImVdwREA0Afhj8kRAN8sPN4EtSDmJGF0J2J0JC14yhIA4BIo7N8QAMgkaWR0YXQkAAAkcXQhWhsteMsSAPojfKDhTPPgJFshaSpkdAEAKmR0IVoVO3jiEgBlXeERAMokeGJ0JH50AgAtYXQVEQDMEgDjTNHiePT3wBEAyyF4MGR0AwAwYHQSEgDkTKbjIHk2YXQ2YnQVJA4ieDNkdGN0QedAhDNxdGN0DAAAONASAOgSAMRdA8IJ4cBdQwMAMsQRANESAOlMaugRAM8lPUOEPwAALWVdhDnSEgDqTEjpEQDQJFohWicPfQDjY3QSfHQAACotLdMSAOtMWeokwyRacHQhWj8AACdlXcYSANQTAOxkLkRZEQDSJS1gdAwHxOuDIVo8AAAkLg/VEwDuEwDtZC4RANMjLQ9jdD8AACE7D+9sDO5EliAtFWF0PAAAHiwP1hMA8BPCB9CXAMV87xIA1SQPYHQMY3QSIFozAAAbn5nZEQDGEwDxbPLwQIckYXQVBG/gjB4AACPXZOMSAP7//4fWIg8hYHQMPFokLCFLIQMAJCSkIw8tfXQEXCRaYHQSYHQPAwAhZHTkc2B0IWB0FeCMJwAAJGN0NmF0KgEA/3x0AQD/Y3SM9QAAAA==' 


    $bBMP = _QuickLZ_Decompress(_Base64Decode_MS($bBMP))

    Local $hFind = _GDIPlus_BitmapCreateFromMemory($bBMP, True)
    Local $hSource = _ScreenCapture_Capture('', 0, 0, -1, -1, False)
    Local $aCords = _BmpSearch($hSource, $hFind)
    If @error Then Return SetError(@error, ConsoleWrite('Error : Unable to find image' & @LF), 0)

    _WinAPI_DeleteObject($hSource)
    _WinAPI_DeleteObject($hFind)

    MouseMove($aCords[1][2] + $aMouse[0], $aCords[1][3] + $aMouse[1])
    MouseClick($aCords[1][2] + $aMouse[0], $aCords[1][3] + $aMouse[1])

EndFunc

 

Link to comment
Share on other sites

18 minutes ago, Kolokol1 said:

How to add a function correctly?

To correctly add the function to your script, you need to copy and paste the function into your script.

11 minutes ago, Kolokol1 said:

All code is

You have not added the _Base64Decode_MS function to this code. 

Link to comment
Share on other sites

3 minutes ago, Beege said:

You have not added the _Base64Decode_MS function to this code. 

#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <ScreenCapture.au3>
#include <ClipBoard.au3>
#include <ColorConstants.au3>
#include <GDIPlus.au3>
#include <file.au3>
#include "QuickLZ.au3"
#include "BmpSearch.au3"

_ClickPic_0()
Func _ClickPic_0() 

    Local $aMouse[2] = [20, 18]

    ;####### (BinaryStrLen = 10934) #### (CompStrLen = 1474) #### (Base64StrLen = 984 ) #####################################################################
    Local $bBMP = 'AkvfAgAAWhUAAICqGMZCTVoVAAAABAA2BAAoBAArBAApBAABABgEABAAxA4AAGjYGAD39vVgdH7/MQaGBABgdP9wdAMA/3x0AAD/YHT/YnQSAAAkn5nWYnQSY3QknpnUYHQkAAAhZV3CEAC9JEtjdDBlXb8PYAAYwAC2ZV2+YHQhAAAeZV3DEQDOEgDlEQDNIUstJOYQAMURANoQAMQg9yEDhy6AAAAb5IwQAL4SAOZMhKA9Ky3mxhEA2yxp2uTXwK4eAAAjz0CELWVdwBAAxxEA3fiH8IMRANwkaQSXJOZgdB4DACNkOcBYKC5pyBEA3iwP3RAAxiPmIWR0AwAhZHQsWsBYImVdwREA0Afhj8kRAN8sPN4EtSDmJGF0J2J0JC14yhIA4BIo7N8QAMgkaWR0YXQkAAAkcXQhWhsteMsSAPojfKDhTPPgJFshaSpkdAEAKmR0IVoVO3jiEgBlXeERAMokeGJ0JH50AgAtYXQVEQDMEgDjTNHiePT3wBEAyyF4MGR0AwAwYHQSEgDkTKbjIHk2YXQ2YnQVJA4ieDNkdGN0QedAhDNxdGN0DAAAONASAOgSAMRdA8IJ4cBdQwMAMsQRANESAOlMaugRAM8lPUOEPwAALWVdhDnSEgDqTEjpEQDQJFohWicPfQDjY3QSfHQAACotLdMSAOtMWeokwyRacHQhWj8AACdlXcYSANQTAOxkLkRZEQDSJS1gdAwHxOuDIVo8AAAkLg/VEwDuEwDtZC4RANMjLQ9jdD8AACE7D+9sDO5EliAtFWF0PAAAHiwP1hMA8BPCB9CXAMV87xIA1SQPYHQMY3QSIFozAAAbn5nZEQDGEwDxbPLwQIckYXQVBG/gjB4AACPXZOMSAP7//4fWIg8hYHQMPFokLCFLIQMAJCSkIw8tfXQEXCRaYHQSYHQPAwAhZHTkc2B0IWB0FeCMJwAAJGN0NmF0KgEA/3x0AQD/Y3SM9QAAAA==' 


    $bBMP = _QuickLZ_Decompress(_Base64Decode_MS($bBMP))

    Local $hFind = _GDIPlus_BitmapCreateFromMemory($bBMP, True)
    Local $hSource = _ScreenCapture_Capture('', 0, 0, -1, -1, False)
    Local $aCords = _BmpSearch($hSource, $hFind)
    If @error Then Return SetError(@error, ConsoleWrite('Error : Unable to find image' & @LF), 0)

    _WinAPI_DeleteObject($hSource)
    _WinAPI_DeleteObject($hFind)

    MouseMove($aCords[1][2] + $aMouse[0], $aCords[1][3] + $aMouse[1])
    MouseClick($aCords[1][2] + $aMouse[0], $aCords[1][3] + $aMouse[1])

EndFunc

Func _Base64Decode_MS($input_string)
    Local $tInput = DllStructCreate('char[' & StringLen($input_string) + 1 & ']')
    DllStructSetData($tInput, 1, $input_string & 0)
    Local $aSize = DllCall("Crypt32.dll", "bool", "CryptStringToBinary", "struct*", $tInput, "dword", 0, "dword", 1, "ptr", 0, "dword*", 0, "ptr", 0, "ptr", 0)
    Local $tDecoded = DllStructCreate("byte[" & $aSize[5] & "]")
    Local $aDecode = DllCall("Crypt32.dll", "bool", "CryptStringToBinary", "struct*", $tInput, "dword", 0, "dword", 1, "struct*", $tDecoded, "dword*", $aSize[5], "ptr", 0, "ptr", 0)
    If Not $aDecode[0] Or @error Then Return SetError(1, 0, 0)
    Return DllStructGetData($tDecoded, 1)
EndFunc   ;==>_Base64Decode_MS

I've tried. Honestly (But I haven't dealt with by this. I can not

Link to comment
Share on other sites

When I run au3check on code posted above I dont get the error your getting about incorrect parameters. I dont get any errors. 

Link to comment
Share on other sites

Im having issues too. I ran the BmpSearch_with_Capture.au3 which worked fine, i then pasted the code from the clipboard into a new au3, the issues started next, and eventually i got the point where i am now:

>Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "C:\Users\W10\Desktop\BmpSearch_with_Capture\123.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
!>10:27:37 AutoIt3.exe ended.rc:-1073741819
+>10:27:37 AutoIt3Wrapper Finished.
>Exit code: 3221225477    Time: 2.991

It just quits and i have no idea why nor time to investigate.

Code i ran:

#include "BmpSearch.au3"
#include "QuickLZ.au3"
#include <GDIPlus.au3>
#include <ScreenCapture.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

 _ClickPic_0()

Func _ClickPic_0()

    Local $aMouse[2] = [155, 32]

    ;####### (BinaryStrLen = 126462) #### (CompStrLen = 10314) #### (Base64StrLen = 6876 ) #####################################################################
    Local $bBMP = 'AksjFAAA/vYAAICqGMZCTf72AAAABAA2BAAoBADGBABqBAABABgEABAAxA4AAGjYGAD////g///zf3Dw4P//4P9RAADg///g///g/1QAD//i///h/1YAD//h///i///h///h/6wAANzb2uAM/+AM/+A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b29vhIGEgYyLJaKLhIHk4yQnZnRgdDBDsEbyZPNj8ydA8wy57/9KyiBkQqBgGZCP+nQ7sk1LfvyPmKPF3ISPZJKlpOTmRFGfnp6kvkGwJEGwKmR05HNgdDBwdOCMb4Rmsb18fHtFS/Dv7uSfRUt5eQ7dmId4BBZmeWB0ddHyTdDEavFE5aQErQTwpTWkNUvO8GS6dbrM72SaRIskazZryu1o0f////8gZEHgyBrD3EJgdA9AsC1idDZidHWAZgxidEJCsERidJlgDUJidKthdIpCsN1CS0JidP9gdDZCsN1gdP9gdHhAsP9gNlZgdP9AsP9jNv9gNlZAsP9gNv9hNv8iZ6z/////YHT/QLD/YDb/YDZxAIf/YDb/YDZWABz/AEr/AEpWAA//4f//4P//4f//4v+u4f//4f//4P9UAA//4P//4P9WAA//4P//4///4P//4P+sAA//4P//4f//4P//4P+qAAAAgP//AAA='

    $bBMP = _QuickLZ_Decompress(_Base64Decode_MS($bBMP))

    Local $hFind = _GDIPlus_BitmapCreateFromMemory($bBMP, True)
    Local $hSource = _ScreenCapture_Capture('', 0, 0, -1, -1, False)
    Local $aCords = _BmpSearch($hSource, $hFind)
    If @error Then Return SetError(@error, ConsoleWrite('Error : Unable to find image' & @LF), 0)

    _WinAPI_DeleteObject($hSource)
    _WinAPI_DeleteObject($hFind)

    MouseMove($aCords[1][2] + $aMouse[0], $aCords[1][3] + $aMouse[1])
    ;MouseClick($aCords[1][2] + $aMouse[0], $aCords[1][3] + $aMouse[1])

EndFunc

Func _Base64Decode_MS($input_string)
    Local $tInput = DllStructCreate('char[' & StringLen($input_string) + 1 & ']')
    DllStructSetData($tInput, 1, $input_string & 0)
    Local $aSize = DllCall("Crypt32.dll", "bool", "CryptStringToBinary", "struct*", $tInput, "dword", 0, "dword", 1, "ptr", 0, "dword*", 0, "ptr", 0, "ptr", 0)
    Local $tDecoded = DllStructCreate("byte[" & $aSize[5] & "]")
    Local $aDecode = DllCall("Crypt32.dll", "bool", "CryptStringToBinary", "struct*", $tInput, "dword", 0, "dword", 1, "struct*", $tDecoded, "dword*", $aSize[5], "ptr", 0, "ptr", 0)
    If Not $aDecode[0] Or @error Then Return SetError(1, 0, 0)
    Return DllStructGetData($tDecoded, 1)
EndFunc   ;==>_Base64Decode_MS

Portion im searching for, available in all windows 10.

 

Capture.PNG

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

  • 4 weeks later...
On 31/10/2018 at 10:00 AM, InnI said:

I used _BmpSearch quite often. And I made some changes to improve usability:

  • now it is not a UDF, but a function
  • now the function accepts not only gdi32 hBitmap, but also GDI+ hImage or simply path to image file
  • now there is no problem with the alpha channel
  • now you can search for a 1x1 pixel image and get array of pixels
  • now the search time is returned to the $aCoords[0][1] in milliseconds
  • added error checking
#include <GDIPlus.au3>

#pragma compile(x64, false)

; #FUNCTION# ====================================================================================================================
; Name          : _BmpSearchEx
; Description   : Searches for Bitmap in a Bitmap
; Syntax        : _BmpSearchEx($vPic1, $vPic2, $iMax = 5000)
; Parameters    : $vPic1   - Handle to bitmap (gdi32 or GDI+) to search or path to image file
;               : $vPic2   - Handle to bitmap (gdi32 or GDI+) to find or path to image file
;               : $iMax    - Max matches to find
; Return values : Success: Returns a 2d array with the following format:
;               :          $aCoords[0][0]  = Total matches found (0 if not found)
;               :          $aCoords[0][1]  = Time of search in ms
;               :          $aCoords[$i][1] = Width of bitmap
;               :          $aCoords[$i][2] = Height of bitmap
;               :          $aCoords[$i][3] = X coordinate
;               :          $aCoords[$i][4] = Y coordinate
;               : Failure: Returns 0 and sets @error:
;               :          @error = 1 - file $vPic1 not found
;               :          @error = 2 - file $vPic2 not found
;               :          @error = 3 - $vPic1 is not a bitmap
;               :          @error = 4 - $vPic2 is not a bitmap
;               :          @error = 5 - error decode opcode
; Author        : Brian J Christy (Beege)
; Modified      : InnI
; ===============================================================================================================================
Func _BmpSearchEx($vPic1, $vPic2, $iMax = 5000)
  If $iMax < 1 Then $iMax = 5000
  Local $hImg1, $hImg2, $iErr1, $iErr2, $iTime = TimerInit()
  _GDIPlus_Startup()
  If IsString($vPic1) Then
    If Not FileExists($vPic1) Then Return SetError(1, _GDIPlus_Shutdown(), 0)
    $hImg1 = _GDIPlus_BitmapCreateFromFile($vPic1)
  Else
    $hImg1 = _GDIPlus_BitmapCreateFromHBITMAP($vPic1)
    $iErr1 = @error
  EndIf
  If IsString($vPic2) Then
    If Not FileExists($vPic2) Then Return SetError(2, _GDIPlus_Shutdown(), 0)
    $hImg2 = _GDIPlus_BitmapCreateFromFile($vPic2)
  Else
    $hImg2 = _GDIPlus_BitmapCreateFromHBITMAP($vPic2)
    $iErr2 = @error
  EndIf
  $hSource = ($iErr1) ? _GDIPlus_BitmapCreateHBITMAPFromBitmap($vPic1) : _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImg1)
  _GDIPlus_BitmapDispose($hImg1)
  $hFind = ($iErr2) ? _GDIPlus_BitmapCreateHBITMAPFromBitmap($vPic2) : _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImg2)
  _GDIPlus_BitmapDispose($hImg2)
  _GDIPlus_Shutdown()
  Static Local $aMemBuff, $tMem, $fStartup = True
  If $fStartup Then
    ;####### (BinaryStrLen = 490) #### (Base64StrLen = 328 )#####################################################################
    Local $Opcode = 'yBAAAFCNRfyJRfSNRfiJRfBYx0X8AAAAAItVDP8yj0X4i10Ii0UYKdiZuQQAAAD38YnBi0X4OQN0CoPDBOL36akAAACDfSgAdB1TA10oO10YD4OVAAAAi1UkORN1A1vrBluDwwTrvVOLVSyLRTADGjtdGHd3iwg5C3UhA1oEi0gEO10Yd2Y5C3USA1oIi0gIO10Yc1c5' & _
        'C3UDW+sGW4PDBOuCi1UUid6LfQyLTRCJ2AHIO0UYczfzp4P5AHcLSoP6AHQNA3Uc6+KDwwTpVP///4tFIIkYg0UgBIPDBP9F/ItVNDlV/HQG6Tj///9bi0X8ycIwAA=='
    Local $aDecode = DllCall("Crypt32.dll", "bool", "CryptStringToBinary", "str", $Opcode, "dword", 0, "dword", 1, "struct*", DllStructCreate("byte[254]"), "dword*", 254, "ptr", 0, "ptr", 0)
    If @error Or (Not $aDecode[0]) Then Return SetError(5, 0, 0)
    $Opcode = BinaryMid(DllStructGetData($aDecode[4], 1), 1, $aDecode[5])
    $aMemBuff = DllCall("kernel32.dll", "ptr", "VirtualAlloc", "ptr", 0, "ulong_ptr", BinaryLen($Opcode), "dword", 4096, "dword", 64)
    $tMem = DllStructCreate('byte[' & BinaryLen($Opcode) & ']', $aMemBuff[0])
    DllStructSetData($tMem, 1, $Opcode)
    ;############################################################################################################################
    $fStartup = False
  EndIf
  Local $tSizeSource = _WinAPI_GetBitmapDimension($hSource)
  If @error Then Return SetError(3, 0, 0)
  Local $tSizeFind = _WinAPI_GetBitmapDimension($hFind)
  If @error Then Return SetError(4, 0, 0)
  Local $iRowInc = ($tSizeSource.X - $tSizeFind.X) * 4
  Local $tSource = DllStructCreate('dword[' & ($tSizeSource.X * $tSizeSource.Y) & ']')
  _WinAPI_GetBitmapBits($hSource, DllStructGetSize($tSource), DllStructGetPtr($tSource))
  Local $tFind = DllStructCreate('dword[' & ($tSizeFind.X * $tSizeFind.Y) & ']')
  _WinAPI_GetBitmapBits($hFind, DllStructGetSize($tFind), DllStructGetPtr($tFind))
  ;####### (BinaryStrLen = 106) #################################################################################################
  Static Local $Opcode_ = '0xC80000008B5D0C8B1383C3048B4D103913750C83C304E2F7B800000000EB118B5508FF338F028B451029C883C002EB00C9C20C00'
  Static Local $aMemBuff_ = DllCall("kernel32.dll", "ptr", "VirtualAlloc", "ptr", 0, "ulong_ptr", BinaryLen($Opcode_), "dword", 4096, "dword", 64)
  Static Local $tMem_ = DllStructCreate('byte[' & BinaryLen($Opcode_) & ']', $aMemBuff_[0])
  DllStructSetData($tMem_, 1, $Opcode_)
  ;##############################################################################################################################
  Local $iFirstDiffIdx, $iFirstDiffPix, $aFirstDiffCoords[2], $iMaxLoops = (DllStructGetSize($tFind) / 4) - 1
  If $iMaxLoops Then
    Local $aFD = DllCallAddress('dword', DllStructGetPtr($tMem_), 'dword*', 0, 'struct*', $tFind, 'dword', $iMaxLoops)
    $iFirstDiffIdx = $aFD[0]
    $iFirstDiffPix = $aFD[1]
  Else
    $iFirstDiffIdx = 1
    $iFirstDiffPix = DllStructGetData($tFind, 1, 1)
  EndIf
  $aFirstDiffCoords[1] = Int(($iFirstDiffIdx - 1) / $tSizeFind.X)
  $aFirstDiffCoords[0] = ($iFirstDiffIdx - 1) - ($aFirstDiffCoords[1] * $tSizeFind.X)
  Local $iFirst_Diff_Inc = (($aFirstDiffCoords[1] * $tSizeSource.X) + $aFirstDiffCoords[0]) * 4
  If $iFirst_Diff_Inc < 0 Then $iFirst_Diff_Inc = 0
  Local $tCornerPixs = DllStructCreate('dword[3]')
  DllStructSetData($tCornerPixs, 1, DllStructGetData($tFind, 1, $tSizeFind.X), 1)
  DllStructSetData($tCornerPixs, 1, DllStructGetData($tFind, 1, $tSizeFind.X * ($tSizeFind.Y - 1) + 1), 2)
  DllStructSetData($tCornerPixs, 1, DllStructGetData($tFind, 1, $tSizeFind.X * $tSizeFind.Y), 3)
  Local $tCornerInc = DllStructCreate('dword[3]')
  DllStructSetData($tCornerInc, 1, ($tSizeFind.X - 1) * 4, 1)
  DllStructSetData($tCornerInc, 1, (($tSizeSource.X - $tSizeFind.X) + $tSizeSource.X * ($tSizeFind.Y - 2) + 1) * 4, 2)
  DllStructSetData($tCornerInc, 1, ($tSizeFind.X - 1) * 4, 3)
  Local $pStart = DllStructGetPtr($tSource)
  Local $iEndAddress = Int($pStart + DllStructGetSize($tSource))
  Local $tFound = DllStructCreate('dword[' & $iMax & ']')
  Local $ret = DllCallAddress('dword', DllStructGetPtr($tMem), 'struct*', $tSource, 'struct*', $tFind, _
      'dword', $tSizeFind.X, 'dword', $tSizeFind.Y, _
      'dword', $iEndAddress, 'dword', $iRowInc, 'struct*', $tFound, _
      'dword', $iFirstDiffPix, 'dword', $iFirst_Diff_Inc, _
      'struct*', $tCornerInc, 'struct*', $tCornerPixs, _
      'dword', $iMax)
  Local $aCoords[$ret[0] + 1][4] = [[$ret[0], Round(TimerDiff($iTime))]]
  If Not $ret[0] Then Return SetError(0, 0, $aCoords)
  For $i = 1 To $ret[0]
    $iFoundIndex = ((DllStructGetData($tFound, 1, $i) - $pStart) / 4) + 1
    $aCoords[$i][3] = Int(($iFoundIndex - 1) / $tSizeSource.X)
    $aCoords[$i][2] = ($iFoundIndex - 1) - ($aCoords[$i][3] * $tSizeSource.X)
    $aCoords[$i][0] = $tSizeFind.X
    $aCoords[$i][1] = $tSizeFind.Y
  Next
  $aCoords[0][1] = Round(TimerDiff($iTime))
  Return SetError(0, 0, $aCoords)
EndFunc  ;==>_BmpSearchEx

 

Hi!

First thanks for this function, very useful!

I'm trying to implement this to a code that i'm writing, that check if a class have space or not and if doesn't have, the code will wait till it have space.

Like this:

$pos[0][0] = 0
While $pos[0][0] = 0
    $pos = _BmpSearchEx($hBMP, $hBitmap, 10)
    Sleep(250)
WEnd

The problem is, if it takes 1hour till have space for example, the program start with just 12mb of ram used, but after just 2min already use 220mb, and so on.

I tried to put the Sleep(250), but that doesn't worked.

There is any solution to the function doesn't use so many ram in a while function?

Thanks!

Link to comment
Share on other sites

14 hours ago, pubeoutros said:

There is any solution to the function doesn't use so many ram in a while function?

Fixed memory leak by adding

_WinAPI_DeleteObject($hSource)
_WinAPI_DeleteObject($hFind)

Thank you for the error found.

Post updated:

Link to comment
Share on other sites

  • 2 weeks later...
On 10/31/2018 at 6:00 AM, InnI said:

I used _BmpSearch quite often. And I made some changes to improve usability:

  • now it is not a UDF, but a function
  • now the function accepts not only gdi32 hBitmap, but also GDI+ hImage or simply path to image file
  • now there is no problem with the alpha channel
  • now you can search for a 1x1 pixel image and get array of pixels
  • now the search time is returned to the $aCoords[0][1] in milliseconds
  • added error checking
#include <GDIPlus.au3>

#pragma compile(x64, false)

; #FUNCTION# ====================================================================================================================
; Name          : _BmpSearchEx
; Description   : Searches for Bitmap in a Bitmap
; Syntax        : _BmpSearchEx($vPic1, $vPic2, $iMax = 5000)
; Parameters    : $vPic1   - Handle to bitmap (gdi32 or GDI+) to search or path to image file
;               : $vPic2   - Handle to bitmap (gdi32 or GDI+) to find or path to image file
;               : $iMax    - Max matches to find
; Return values : Success: Returns a 2d array with the following format:
;               :          $aCoords[0][0]  = Total matches found (0 if not found)
;               :          $aCoords[0][1]  = Time of search in ms
;               :          $aCoords[$i][1] = Width of bitmap
;               :          $aCoords[$i][2] = Height of bitmap
;               :          $aCoords[$i][3] = X coordinate
;               :          $aCoords[$i][4] = Y coordinate
;               : Failure: Returns 0 and sets @error:
;               :          @error = 1 - file $vPic1 not found
;               :          @error = 2 - file $vPic2 not found
;               :          @error = 3 - $vPic1 is not a bitmap
;               :          @error = 4 - $vPic2 is not a bitmap
;               :          @error = 5 - error decode opcode
; Author        : Brian J Christy (Beege)
; Modified      : InnI
; ===============================================================================================================================
Func _BmpSearchEx($vPic1, $vPic2, $iMax = 5000)
  If $iMax < 1 Then $iMax = 5000
  Local $hImg1, $hImg2, $iErr1, $iErr2, $iTime = TimerInit()
  _GDIPlus_Startup()
  If IsString($vPic1) Then
    If Not FileExists($vPic1) Then Return SetError(1, _GDIPlus_Shutdown(), 0)
    $hImg1 = _GDIPlus_BitmapCreateFromFile($vPic1)
  Else
    $hImg1 = _GDIPlus_BitmapCreateFromHBITMAP($vPic1)
    $iErr1 = @error
  EndIf
  If IsString($vPic2) Then
    If Not FileExists($vPic2) Then Return SetError(2, _GDIPlus_Shutdown(), 0)
    $hImg2 = _GDIPlus_BitmapCreateFromFile($vPic2)
  Else
    $hImg2 = _GDIPlus_BitmapCreateFromHBITMAP($vPic2)
    $iErr2 = @error
  EndIf
  $hSource = ($iErr1) ? _GDIPlus_BitmapCreateHBITMAPFromBitmap($vPic1) : _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImg1)
  If Not $iErr1 Then _GDIPlus_BitmapDispose($hImg1)
  $hFind = ($iErr2) ? _GDIPlus_BitmapCreateHBITMAPFromBitmap($vPic2) : _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImg2)
  If Not $iErr2 Then _GDIPlus_BitmapDispose($hImg2)
  _GDIPlus_Shutdown()
  Static Local $aMemBuff, $tMem, $fStartup = True
  If $fStartup Then
    ;####### (BinaryStrLen = 490) #### (Base64StrLen = 328 )#####################################################################
    Local $Opcode = 'yBAAAFCNRfyJRfSNRfiJRfBYx0X8AAAAAItVDP8yj0X4i10Ii0UYKdiZuQQAAAD38YnBi0X4OQN0CoPDBOL36akAAACDfSgAdB1TA10oO10YD4OVAAAAi1UkORN1A1vrBluDwwTrvVOLVSyLRTADGjtdGHd3iwg5C3UhA1oEi0gEO10Yd2Y5C3USA1oIi0gIO10Yc1c5' & _
        'C3UDW+sGW4PDBOuCi1UUid6LfQyLTRCJ2AHIO0UYczfzp4P5AHcLSoP6AHQNA3Uc6+KDwwTpVP///4tFIIkYg0UgBIPDBP9F/ItVNDlV/HQG6Tj///9bi0X8ycIwAA=='
    Local $aDecode = DllCall("Crypt32.dll", "bool", "CryptStringToBinary", "str", $Opcode, "dword", 0, "dword", 1, "struct*", DllStructCreate("byte[254]"), "dword*", 254, "ptr", 0, "ptr", 0)
    If @error Or (Not $aDecode[0]) Then Return SetError(5, 0, 0)
    $Opcode = BinaryMid(DllStructGetData($aDecode[4], 1), 1, $aDecode[5])
    $aMemBuff = DllCall("kernel32.dll", "ptr", "VirtualAlloc", "ptr", 0, "ulong_ptr", BinaryLen($Opcode), "dword", 4096, "dword", 64)
    $tMem = DllStructCreate('byte[' & BinaryLen($Opcode) & ']', $aMemBuff[0])
    DllStructSetData($tMem, 1, $Opcode)
    ;############################################################################################################################
    $fStartup = False
  EndIf
  Local $tSizeSource = _WinAPI_GetBitmapDimension($hSource)
  If @error Then Return SetError(3, 0, 0)
  Local $tSizeFind = _WinAPI_GetBitmapDimension($hFind)
  If @error Then Return SetError(4, 0, 0)
  Local $iRowInc = ($tSizeSource.X - $tSizeFind.X) * 4
  Local $tSource = DllStructCreate('dword[' & ($tSizeSource.X * $tSizeSource.Y) & ']')
  _WinAPI_GetBitmapBits($hSource, DllStructGetSize($tSource), DllStructGetPtr($tSource))
  Local $tFind = DllStructCreate('dword[' & ($tSizeFind.X * $tSizeFind.Y) & ']')
  _WinAPI_GetBitmapBits($hFind, DllStructGetSize($tFind), DllStructGetPtr($tFind))
  _WinAPI_DeleteObject($hSource)
  _WinAPI_DeleteObject($hFind)
  ;####### (BinaryStrLen = 106) #################################################################################################
  Static Local $Opcode_ = '0xC80000008B5D0C8B1383C3048B4D103913750C83C304E2F7B800000000EB118B5508FF338F028B451029C883C002EB00C9C20C00'
  Static Local $aMemBuff_ = DllCall("kernel32.dll", "ptr", "VirtualAlloc", "ptr", 0, "ulong_ptr", BinaryLen($Opcode_), "dword", 4096, "dword", 64)
  Static Local $tMem_ = DllStructCreate('byte[' & BinaryLen($Opcode_) & ']', $aMemBuff_[0])
  DllStructSetData($tMem_, 1, $Opcode_)
  ;##############################################################################################################################
  Local $iFirstDiffIdx, $iFirstDiffPix, $aFirstDiffCoords[2], $iMaxLoops = (DllStructGetSize($tFind) / 4) - 1
  If $iMaxLoops Then
    Local $aFD = DllCallAddress('dword', DllStructGetPtr($tMem_), 'dword*', 0, 'struct*', $tFind, 'dword', $iMaxLoops)
    $iFirstDiffIdx = $aFD[0]
    $iFirstDiffPix = $aFD[1]
  Else
    $iFirstDiffIdx = 1
    $iFirstDiffPix = DllStructGetData($tFind, 1, 1)
  EndIf
  $aFirstDiffCoords[1] = Int(($iFirstDiffIdx - 1) / $tSizeFind.X)
  $aFirstDiffCoords[0] = ($iFirstDiffIdx - 1) - ($aFirstDiffCoords[1] * $tSizeFind.X)
  Local $iFirst_Diff_Inc = (($aFirstDiffCoords[1] * $tSizeSource.X) + $aFirstDiffCoords[0]) * 4
  If $iFirst_Diff_Inc < 0 Then $iFirst_Diff_Inc = 0
  Local $tCornerPixs = DllStructCreate('dword[3]')
  DllStructSetData($tCornerPixs, 1, DllStructGetData($tFind, 1, $tSizeFind.X), 1)
  DllStructSetData($tCornerPixs, 1, DllStructGetData($tFind, 1, $tSizeFind.X * ($tSizeFind.Y - 1) + 1), 2)
  DllStructSetData($tCornerPixs, 1, DllStructGetData($tFind, 1, $tSizeFind.X * $tSizeFind.Y), 3)
  Local $tCornerInc = DllStructCreate('dword[3]')
  DllStructSetData($tCornerInc, 1, ($tSizeFind.X - 1) * 4, 1)
  DllStructSetData($tCornerInc, 1, (($tSizeSource.X - $tSizeFind.X) + $tSizeSource.X * ($tSizeFind.Y - 2) + 1) * 4, 2)
  DllStructSetData($tCornerInc, 1, ($tSizeFind.X - 1) * 4, 3)
  Local $pStart = DllStructGetPtr($tSource)
  Local $iEndAddress = Int($pStart + DllStructGetSize($tSource))
  Local $tFound = DllStructCreate('dword[' & $iMax & ']')
  Local $ret = DllCallAddress('dword', DllStructGetPtr($tMem), 'struct*', $tSource, 'struct*', $tFind, _
      'dword', $tSizeFind.X, 'dword', $tSizeFind.Y, _
      'dword', $iEndAddress, 'dword', $iRowInc, 'struct*', $tFound, _
      'dword', $iFirstDiffPix, 'dword', $iFirst_Diff_Inc, _
      'struct*', $tCornerInc, 'struct*', $tCornerPixs, _
      'dword', $iMax)
  Local $aCoords[$ret[0] + 1][4] = [[$ret[0], Round(TimerDiff($iTime))]]
  If Not $ret[0] Then Return SetError(0, 0, $aCoords)
  For $i = 1 To $ret[0]
    $iFoundIndex = ((DllStructGetData($tFound, 1, $i) - $pStart) / 4) + 1
    $aCoords[$i][3] = Int(($iFoundIndex - 1) / $tSizeSource.X)
    $aCoords[$i][2] = ($iFoundIndex - 1) - ($aCoords[$i][3] * $tSizeSource.X)
    $aCoords[$i][0] = $tSizeFind.X
    $aCoords[$i][1] = $tSizeFind.Y
  Next
  $aCoords[0][1] = Round(TimerDiff($iTime))
  Return SetError(0, 0, $aCoords)
EndFunc  ;==>_BmpSearchEx

 

can you compare between this and the one i have been using - imagesearchex; i'm not sure which one's more optimized; 

edit; they're complimentary not substitutes. Some reason, if i run too many searches for too long (with sleeps inbetween still) it'll crash and tell me error below. Any ideas why?

 

Local $iRowInc = ($tSizeSource.X - $tSizeFind.X) * 4
Local $iRowInc = ($tSizeSource^ ERROR

imageSearchEX.au3

Edited by deleteme_yes
Link to comment
Share on other sites

  • 1 month later...

Hi, very useful script! Could point me in the right direction to add a tolerance value like in _ImageSearchArea ?

 

I don't see where in your code that you compare 2 pixels at a time so maybe that's not the way you do it. I'd like to make it so that when the rgb of the pixel is off by lee than $tolerance, it still matches it.

 

Any help is appreciated.

Looking forward to using it in my script!

Link to comment
Share on other sites

  • 3 months later...
On 1/14/2019 at 9:39 AM, InnI said:

Fixed memory leak by adding

_WinAPI_DeleteObject($hSource)
_WinAPI_DeleteObject($hFind)

Thank you for the error found.

Post updated:

It's possible to add some tolerance to this function? Sometimes it doesn't find the image just because of a simple tolerance.

Thanks!

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