Jump to content

HandleImgSearch (Image Search with ImageSearchDLL embedded)


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 post
Share on other sites
  • Developers
Posted (edited)

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 post
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 post
Share on other sites
8 hours ago, piibomja said:

@lamnhan066 Step 2 it not  do work . T.T . please help me🤕

RAjOYSx.png 

In your code, I see that you just call `_TestHandle` instead of calling both `_TestHandle` and `_TestHandle2`, so that the STEP 2 doesn't work because it isn't called.

Link to post
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 post
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 post
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 post
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 post
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 post
Share on other sites
Posted (edited)
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 post
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 post
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 post
Share on other sites
Posted (edited)
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 post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By SolemnStrike
      Hey, 
      I know the title sounds weird, but i couldn't find better words for it...
      I finally managed to have a working image search (yes yes i know image search is evil :p).
      I noticed that even if the script is compiled, the images have to be in my script folder.
      But i don't want that the images i'm searching for on the screen can be viewed, edited etc by every user.
      Is there a way to... uhm... put them in a file like .rar, but one that can't be easily opened? 🤔
       
      Edit: Now that i think of .rar, maybe using a .rar which is protected by a password... Can autoit search, open, extract, use and delete that? (I guess so, I didn't search for this yet, going to google that asap)
    • By lenclstr746
      Hi guys,
      Some functions of my script are running slowly. Very slow. What is the reason?
      My Code:
      <snip>
    • By Atoxis
      Howdy, I've gone through a lot of au3 forums, and I once had a working Imagesearch script that I got from here.  However, and i'm just totally not sure how but my imagesearch scripts aren't working anymore.
      I'm not new to au3 but i'm not the most experienced with it's syntax/commands.

      Anyways, I've looked over the big threads involving imagesearch.

      Does anyone have a working Imagesearch x64 for win10 that is currently working as of the date with the post.

      Dll's and what not is fine, just when I tell the script to run, I want to be able to find the image on the screen!
      Can't find a working copy so if anyone has one please send it my way lol.

      I've taken all the imagesearch downloads and what not and have played with them but I can't get any of them working on my end, despite others saying they're working.
      Thanks.
    • By Ian_Mac
      Func dg_get_images() $x1=0 $y1=0 ;MsgBox(0,"start","start") do $result = _ImageSearch("C:\Users\Server\Desktop\my project\image.png",1,$x1,$y1,0) until $result = 1; if $result=1 Then MouseMove($x1,$y1,3) MouseClick("left", $x1,$y1, 1) WinWait("[Title:TightVNC File Transfer]", "", 10) EndIf  this code works when i search the image, but when i change the location of the desktop icon it can't find the desktop icon anymore.   i wanna try image search area. but i don't know how to use it because i cant understand the parameter for the image search area.  please help me how to solve it thank you in advance.
    • By knuxfighter
      Hello. I've been working with Imagesearch library lately and it did a good work, although I moved to a new PC and didn't copy the old files with me so I downloaded the Imagesearch from the following post
       hoping that it will work. It doesn't though. First time I when I use (run as subscript to my code) the Imagesearch.au3, Scite finds errors (missing spaces). Ctrl+T (scite tidy) fixes these missing spaces but the script returns the following error on every run after:
      _ImageSearch('search.bmp', 0, $x, $y, 0) outputs
       
      "C:\Users\Knuckles\Desktop\AutoIt\include\ImageSearch.au3" (44) : ==> Subscript used on non-accessible variable.: If $result[0] = "0" Then Return 0 If $result^ ERROR no matter if I put the searched bmp in the script folder or folder img in the script directory. Also, it doesn't matter if the searched image on screen or not, it returns the same.

      Can you provide me any help please? I remember having these problems 2 years ago when I first met the imagesearch library also (I fixed it somehow though in that time). Seems nothing changed.

      Using this version posted in the following post gives the same error:
      Also I run windows 10 64bit and I have no shell options for script editing, running as x86 or whatever as I used to have on windows xp/7. I went through some steps like deleting a key in registry and I even reinstalled autoit and scite but that only resulted to au3 as unrecognized file format and not in getting back the menus and the icon on au3 files. Any thoughts on this?

      Edit: Installing 64-bit AutoIt and using 64bit ImageSearch is no change.
      code.au3

      FOUND WORKING: http://www.codebot.de/index.php/Thread/12713-Imagesearch-au3-funktioniert-nicht/
       but why is this one working and the original aren't? :(
×
×
  • Create New...