ImageSearch Tips & Tricks

Put simple Tips and Tricks that are not entire Tutorials in this forum
go1
Posts: 13
Joined: 17 Sep 2018, 17:14

Re: ImageSearch Tips & Tricks

Post by go1 » 09 Jun 2020, 16:06

Comma after word "Tooltip" does nothing according to coding tests + docs. However after word "image" and "found" it did messed it up.
Regarding second tooltip,i was told by someone back in early 2019 at ahk discord that the AHK reads it top to down and braces are not necessary after errorlevels.
Need to remove my rustiness in ahk coding since i made literally coding equivalent of "spelling mistakes".
Sorry if it angered you when it meant to help.

User avatar
boiler
Posts: 16710
Joined: 21 Dec 2014, 02:44

Re: ImageSearch Tips & Tricks

Post by boiler » 09 Jun 2020, 17:48

I don’t know why you think I’m angry. I was trying to help by pointing out the things that will make it work the way you intended. Sorry if that’s how you took it.

I wasn’t talking about the comma after the word ToolTip. Commas after command names are always optional. I’m saying that within a parameter, you can’t have a non-escaped comma or else it will think you’re starting a new parameter, which you found to be true.

Unfortunately, it sounds like you got some incorrect advice about braces after an ErrorLevel. I thought you would prefer to hear the correct advice. That’s how the rust gets knocked off. People on the forum help each other by showing them the correct or better ways to do things. I still learn things from the forum every day. I’ll make a note that you prefer not to get feedback on your code. Sorry for the trouble.

go1
Posts: 13
Joined: 17 Sep 2018, 17:14

Re: ImageSearch Tips & Tricks

Post by go1 » 10 Jun 2020, 22:13

Thank you,it's great to learn new things,i'll test your idea and it's performance for my future projects.

wedwo
Posts: 3
Joined: 12 Aug 2021, 04:40

Re: ImageSearch Tips & Tricks

Post by wedwo » 12 Aug 2021, 04:55

I'm struggling with ImageSearch. In a nutshell, what I'm trying to do is see if a text search in chrome browser produces 0 results or not. For example, if I search for the string +delete, I have this on the screen:

image.png
image.png (32.71 KiB) Viewed 5271 times

Now using Window spy, I've determined (I believe correctly) that on my screen, the text 0/0 should be found somewhere between 1285,105:

image.png
image.png (123.94 KiB) Viewed 5271 times

and 1336,134...

image.png
image.png (128.7 KiB) Viewed 5271 times

The image I'm using is a screen capture of the section with the 0/0 text. I've tried searching the entire screen but it doesn't find anything. What am I doing wrong, or is this not something I can do with imagesearch?

My code looks like this:

Code: Select all

Run, https://www.google.com
Sleep 4000
Send ^f
Sleep 100
Send {+}delete
Sleep 5000
Imagesearch, FoundX , FoundY , 1285, 105, 1336, 134, e:\users\myuser\pictures\0.jpg
if (ErrorLevel = 2)
    MsgBox Could not conduct the search.
else if (ErrorLevel = 1)
    MsgBox The image was not found
else
    MsgBox The image was found!

wedwo
Posts: 3
Joined: 12 Aug 2021, 04:40

Re: ImageSearch Tips & Tricks

Post by wedwo » 12 Aug 2021, 04:59

For reference (I couldn't attach a fourth image to my previous post), this is the image I'm looking for:
image.png
image.png (691 Bytes) Viewed 5268 times

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: ImageSearch Tips & Tricks

Post by swagfag » 12 Aug 2021, 05:08

dont use lossy formats to search with(ur jpg needle image is artifacting due to compression, so it no longer matches whats actually on screen)

wedwo
Posts: 3
Joined: 12 Aug 2021, 04:40

Re: ImageSearch Tips & Tricks

Post by wedwo » 12 Aug 2021, 07:56

swagfag wrote:
12 Aug 2021, 05:08
dont use lossy formats to search with(ur jpg needle image is artifacting due to compression, so it no longer matches whats actually on screen)
Spot on! Thanks for your help - 32 bit non-interlaced png did the trick

grosner
Posts: 10
Joined: 11 Sep 2016, 13:08

Re: ImageSearch Tips & Tricks

Post by grosner » 19 Sep 2022, 20:25

Hoping smaller image files would improve search time, I changed the search image bit-depth from 32bit to 8bit. Reliability signficantly improved when I recaptured and saved the image as 32bit!

kashmirLZ
Posts: 27
Joined: 06 Oct 2022, 23:27

Re: ImageSearch Tips & Tricks

Post by kashmirLZ » 19 Feb 2023, 02:12

Is it normal for shade-variation to have to use values around 80? I took an exact screenshot and saved it as a PNG. How can there be so much variation...?

Oh that's weird -- now it's working with really low values. Okay.


Post Reply

Return to “Tips and Tricks (v1)”