Jump to content

HandleImgSearch (Image Search with ImageSearchDLL embedded)


lamnhan066
 Share

Recommended Posts

Quote

     Me open LD-player 3 screen

j3SqNnE.png

Quote

 1. wan code Find ImgSearch background .

 2. if find picture Click picture in background (can Click Overlays)
ex.Whatsapp


me will do bot game , haha ,    Thank you very much  😄

XG5Oe1c.png

Link to comment
Share on other sites

  • Developers

Why are you cross posting your question in multiple places? Are you in a hurry or something?

 Stick to this thread please.   posts merged.

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Jos locked and unlocked this topic
2 minutes ago, Jos said:

Why are you cross posting your question in multiple places? Are you in a hurry or something?

 Stick to this thread please.   posts merged.

Me sorry, me Sorry
Join New 🙏 , next me will not do

please help ... autoit
 

Link to comment
Share on other sites

  • 3 weeks later...

my call 

$aCords = _HandleImgSearch($device, $bmpLocal, $startX, $startY, $startWidth, $startHeight, 70, 20)

 

I'm unable to find my image on my left most screen of a 3 monitor setup (-1920, 0 top left).  When I change the image search range and location of image to middle monitor (0, 0) it works.

I noticed __ImageSearch is called with hard coded values of 0,0 in it's x and y parameters in the bottom of the _HandleImgSearch function. Does this do anything? Maybe I'm going down the wrong rabbit hole.

Local $pos = __ImgSearch(0, 0, _GDIPlus_ImageGetWidth($BMP), _GDIPlus_ImageGetHeight($BMP), $Bitmap, $BMP, $Tolerance, $MaxImg)

EDIT: My image and search are successful when searching with another ImageSearch solution found here. I'm only linking for people in the future who might have this same issue or to help someone fix the issue as I was unable to.

Edited by tantrim
Link to comment
Share on other sites

On 4/19/2022 at 7:46 AM, tantrim said:

my call 

$aCords = _HandleImgSearch($device, $bmpLocal, $startX, $startY, $startWidth, $startHeight, 70, 20)

 

I'm unable to find my image on my left most screen of a 3 monitor setup (-1920, 0 top left).  When I change the image search range and location of image to middle monitor (0, 0) it works.

I noticed __ImageSearch is called with hard coded values of 0,0 in it's x and y parameters in the bottom of the _HandleImgSearch function. Does this do anything? Maybe I'm going down the wrong rabbit hole.

Local $pos = __ImgSearch(0, 0, _GDIPlus_ImageGetWidth($BMP), _GDIPlus_ImageGetHeight($BMP), $Bitmap, $BMP, $Tolerance, $MaxImg)

EDIT: My image and search are successful when searching with another ImageSearch solution found here. I'm only linking for people in the future who might have this same issue or to help someone fix the issue as I was unable to.

The _HandleImgSearch doesn't depend on where the window is if you're using $device as a handle of that window, it just capture that specific window and search $bmpLocal inside it. If you want to search your whole screen, you can try using this code:

$aCords = _HandleImgSearch("", $bmpLocal, $startX, $startY, $startWidth, $startHeight, 70, 20)

When you let the handle = "", the UDF will capture your whole screen or your specific area if you want to and search inside it.

Link to comment
Share on other sites

  • 4 weeks later...

I think _Global_ function should be change to _Static_ function, because it default uses 1 capture to search across script.

I seem don't know your purpose to use _Global_ search.

Btw, thank you for your script!

 

Link to comment
Share on other sites

  • 3 weeks later...
On 5/14/2022 at 11:50 PM, Deathdn said:

I think _Global_ function should be change to _Static_ function, because it default uses 1 capture to search across script.

I seem don't know your purpose to use _Global_ search.

Btw, thank you for your script!

 

It is so easy to make mistakes if you need to capture in a loop and analyze it with multiple functions in 1 capture, so I create build-in _Global functions to mainly manage memory to reduce memory leaks.

I think _Static is not enough meaning because it already uses the global variable to manage the captured photo and uses it across other _Global functions.

Link to comment
Share on other sites

  • 4 weeks later...

Hello, I'm looking for the "TransBlack" or "TransWhite" function, this function is original from ImageSearch DLL that ignores all black or white background of the image, leaving only what matters in the image, however, I can't use it in HandleImageSearch.
Could anyone help me with this?

Link to comment
Share on other sites

On 6/24/2022 at 11:06 PM, nok said:

Hello, I'm looking for the "TransBlack" or "TransWhite" function, this function is original from ImageSearch DLL that ignores all black or white background of the image, leaving only what matters in the image, however, I can't use it in HandleImageSearch.
Could anyone help me with this?

I've implemented this feature to the code but I haven't made it public yet because I don't have time to test it completely right now. You can access the repo here: https://github.com/lamnhan066/HandleImgSearch/tree/add-transparency

You can add 0x000000 (means Black) or 0xFFFFFF (means White) or any color that you want to ignore to the `$Transparency` parameter.

You can check it out and give me the feed back if possible so I can merge it to the main repo. Thank you!

Edited by lamnhan066
Update github URL
Link to comment
Share on other sites

5 hours ago, Deathdn said:

What is color pixel in transparent area of .png image? Is this 0xFFFFFF?

Whatever the color is (except alpha color), you just need to add it to the $Transparency parameter like this example:

On 6/28/2022 at 2:29 PM, lamnhan066 said:

You can add 0x000000 (means Black) or 0xFFFFFF (means White) or any color that you want to ignore to the `$Transparency` parameter.

 

Link to comment
Share on other sites

Hmm..

Hard to say but you code is hard to read and debug. 

Please read more here https://www.autoitscript.com/wiki/Best_coding_practices

 

1. Function __ImgSearch

That should set __ImgSearch($hImgSrc, $hImgFind, $iTolerance, ..)

All of <$x, $y, $right, $bottom> can get by parameters send to __ImgSearch

2. And __ImgSearch should be used to compare 2 Bitmap or 2 hBitmap.

3. Instead send too many parameters to 1 function, why don't you use struct. And set one of it to default compare parameters.

4. Bro có thể tham khảo code mà t viết dựa trên code của bro.

This is my opinion.

_ImageHS_old.au3

Edited by Deathdn
Link to comment
Share on other sites

10 hours ago, Deathdn said:

Hmm..

Hard to say but you code is hard to read and debug. 

Please read more here https://www.autoitscript.com/wiki/Best_coding_practices

Hi,

Here are my thoughts about your opinions:

  1. You're right, this is a function that I worte before anything else so I didn't take care it enough because it's just an internal function, most users don't need to take care it much. 

  2. Because the ImageSearch DLL uses hBitmap for searching, but I want the users just need to input the file path so I have to convert it to hBitmap.

  3. Most of AutoIt users do not so familiar to the Struct, so you can make them harder to understand the code.

  4. Mình đã đọc và cảm ơn bạn đã góp ý nhé, UDF này mình viết từ khoảng thời gian khá sớm sau khi tìm hiểu về AutoIt và không có UDF nào đáp ứng được nhu cầu của mình về độ linh động và không cần đính kèm DLL khi build.

I also moved the BinaryCall.au3, MemoryDll.au3 code to separated file in the new version.

My work does not relate to AutoIt after I finished this UDF so I don't have much time to improve or optimize the code. I have created the new version here, you can create the Issue, PR for your optimization or new features.

Thank you and I very appreciate your suggestion.

 

Edited by lamnhan066
TYPO
Link to comment
Share on other sites

  • 3 months later...

Hi,
thanks for sharing but i am not as experienced and confused about the number of functions in HandleImgSearch as well as the fact, i can not read a lot of it (what happened to the letters?) :(
Can anybody please help me with minium code (no error checks...), how to find a locally saved bmp-file within another locally saved bmp-file with shade variation (tolerance), please?
According to the description, it seems _BmpImgSearch is the right function but when i look at this function, there are parameters which i do not need ($x, $y, width, heigt) because i just want to search a pic in a pic with tolerance. I also can not read the description as it seems something wrong with the letters:

image.png.3d8a3bc89d03f47c6db7ebccb951e5d1.png

Can anybody please help me as i guess the following is the wrong way:
 

#include <Array.au3>
#include "HandleImgSearch.au3"

Local $Find_this_image = @ScriptDir & '\folder_symbol.bmp'
Local $In_this_image = @ScriptDir & '\desktop.bmp'

Local $aResult = _BmpImgSearch($In_this_image, $Find_this_image, 0, 0, @DesktopWidth, @DesktopHeight, 15, 1000)
_ArrayDisplay($aResult)

Many thanks
Tobi

Link to comment
Share on other sites

Hi @tobius,

I wrote these UDF function headers in Vietnamese, so I think your computer shows weird letters because it doesn't support Vietnamese. I will translate it into English when I have time.

And yes, you are using the right function and you don't have to fill in all the parameters if you don't need to.

For instance:

#include <Array.au3>
#include "HandleImgSearch.au3"

Local $Find_this_image = @ScriptDir & '\folder_symbol.bmp'
Local $In_this_image = @ScriptDir & '\desktop.bmp'

Local $aResult = _BmpImgSearch($In_this_image, $Find_this_image)
_ArrayDisplay($aResult)

Since AutoIt doesn't support named parameters, if you want to modify $Tolerance you can fill default values in all parameters before it like below:

#include <Array.au3>
#include "HandleImgSearch.au3"

Local $Find_this_image = @ScriptDir & '\folder_symbol.bmp'
Local $In_this_image = @ScriptDir & '\desktop.bmp'

Local $aResult = _BmpImgSearch($In_this_image, $Find_this_image, 0, 0, -1, -1, 30)
_ArrayDisplay($aResult)

 

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