FindClick() - ImageSearch, Clicking, & More [Newest Version]

Post your working scripts, libraries and tools for AHK v1.1 and older
Oblituarius
Posts: 13
Joined: 31 Mar 2019, 16:57

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

06 Jan 2020, 15:00

Hi @berban It's me again.

I gave up on "db" since it never worked. I tried using the example on P.19 and I always get a blank result or "(,0). Is there a way to use that example or a variation of it to extract %Results% into an Array that I can order up? I know that if I get it to work, I could store %Coords1% and %Coords2% into some variables and then put them into an Array.
That would also work in my case.

Still testing some stuff, it's been a while since I worked on my script. I will probably have to go through FindClick.ahk to see how it is working too.

Thanks!

Edit1: So I managed to get every single instance coord with this code . Probably too much sh*t and it shouldn't be done like this. It's super messy, but it gets the job done:

Code: Select all

TableLoc()
{
	FindClick("Image", "e n Sleep500 oTransBlack,1 a408,680,-443,-329")
	Sort, Results, N R
	Coords := StrSplit(Results, "`n", "`")
	Loop % (Coords.MaxIndex()-1)
	{
		X1_Table_Array[TA1] := Coords[A_Index]
		if (X1_Table_Array[TA1] = X1_Table_Array[TA1-1])
		{
			TA1++
			TA2++
			Tooltip, Sum %TA2%, 1578, 523, 2
		}
		Sleep 800
		Temp1 := X1_Table_Array[TA1]
		Temp2 := X1_Table_Array[TA1]
		
		StartingPos := InStr(Temp1, ",")
		string1 := SubStr(Temp1, 1, 4)
		
		StartingPos := InStr(Temp2, ",")
		string2 := SubStr(Temp2, StartingPos + 1)
		
		Tooltip, %TA3%, %string1%, %string2%, %TA3%
		TA3++
		TA1++
		
		Click1 := Format("{:i}", string1)
		Click2 := Format("{:i}", string2)
		
		MouseGetPos, X, Y
		Random, I, 0, 1 ;Random ellipse invert.
		MouseMove_Ellipse(X, Y, Click1+40, Click2+60, 1, 0, I)
		
		TableFinder()
	}
	return
}
Now, for some reason, I have to leave in oTransBlack,1 or it goes bunkers xd.

This took me solid 8+hrs of research to put together. Kill me.
symaw
Posts: 1
Joined: 17 Mar 2020, 21:40

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

17 Mar 2020, 21:50

Hello.
Does the options "Width and height to which to scale the image" works with "o – ImageSearch Options"?
I can't get it to work:
FindClick("image.jpg", "n oTransBlack,10 ow,44 oh,-1")

It will find the image.jpg at the original size, but not the scaled size.

o – ImageSearch Options
What to give comma-delimited string of imagesearch options
Description The optional parameters for ImageSearch, as shown in the AutoHotkey documentation. Use a comma to separate options instead of a space. You may omit the asterisk (*). For example: oTransBlack,20 makes black transparent and allows 20 shades of variation.

From the AutoHotkey documentation:
Options: Zero or more of the following strings may be also be present immediately before the name of the file. Separate each option from the next with a single space or tab. For example: *2 *w100 *h-1 C:\Main Logo.bmp.
*wn and *hn: Width and height to which to scale the image (this width and height also determines which icon to load from a multi-icon .ICO file). If both these options are omitted, icons loaded from ICO, DLL, or EXE files are scaled to the system's default small-icon size, which is usually 16 by 16 (you can force the actual/internal size to be used by specifying *w0 *h0). Images that are not icons are loaded at their actual size. To shrink or enlarge the image while preserving its aspect ratio, specify -1 for one of the dimensions and a positive number for the other. For example, specifying *w200 *h-1 would make the image 200 pixels wide and cause its height to be set automatically.

Thank you for reply
SmithyZoomZoom
Posts: 111
Joined: 23 Aug 2019, 23:32

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

02 Apr 2020, 20:12

Hello:

When I downloaded Findclick, then I tried to run it, I received an error at line 143:
https://imgur.com/a/MuV7ReI
I tried creating a Lib Folder inside C:\Program Files\AutoHotkey and putting the FindClick AutoHotkey file there. It did not help.
I am unsure how to install this. Any help would be appreciated!
User avatar
Cerberus
Posts: 172
Joined: 12 Jan 2016, 15:46

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

02 Apr 2020, 22:56

SmithyZoomZoom wrote: Hello:

When I downloaded Findclick, then I tried to run it, I received an error at line 143:
https://imgur.com/a/MuV7ReI
I tried creating a Lib Folder inside C:\Program Files\AutoHotkey and putting the FindClick AutoHotkey file there. It did not help.
I am unsure how to install this. Any help would be appreciated!
Are you sure you have downloaded the right code? Because I doubt whether there should be any code like "hydro-" in FindClick. I think you accidentally downloaded the html web page, not the Autohotkey code/script.
SmithyZoomZoom
Posts: 111
Joined: 23 Aug 2019, 23:32

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

03 Apr 2020, 15:15

Yes. I am such a goofball. Thank you so much. If we have questions about FindClick, do we just post them in Asking for Help? I'm trying to click on a game window with a mildly transparent background. I know there's an option to allow for variations in the image, which is like the letter o and then a number: o50 for example. What's the highest amount of variation we can ask it to look for?

Edit – it's one of those situations where when you click on the object, it turns a highlighted color. I want my image search to be able to click on the highlighted and non-highlighted variations of the image. I think this is a circumstance where perhaps I have to use two images and have it search for the highlighted one if it can't find the non-highlighted one. I'm pretty sure that's possible with error levels but I'm not quite sure how.

Thank you for the help. Apologies if this is the wrong place.

Second edit –
After much trial and error, I was able to get the program to do what I needed to do – hooray! (I'm just not exactly sure how. But I think I will take that curiosity question to another thread in the forum.)

Anyway, just wanted to say thank you to @berban because, if I can get it working correctly, they use of this library will enable me to overcome a physical disability and be able to play computer games with my friends. Thanks.
nacken012
Posts: 90
Joined: 22 Jul 2016, 14:39

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

03 Apr 2020, 21:33

Hallo

Was ich nicht verstehe, das er statt dem beige Farbton ein blauen Farbton findet

FindClick("*0xefd36b",,FoundX, FoundY)
Screenshot_5.jpg
Screenshot_5.jpg (86.11 KiB) Viewed 4461 times
Da wo der linke Pfeil ist sollte er finden und finden tut er den blauen Pixel wo der rechte Pfeil ist.

Beim normalen PixelSearch macht er es richtig

PixelSearch, FoundX, FoundY, 0, 0, 1920, 1080, 0xefd36b, 0, Fast RGB
burque505
Posts: 1731
Joined: 22 Jan 2017, 19:37

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

08 Apr 2020, 14:45

@nacken012, hallo

Versuch mal Folgendes:

Code: Select all

FindClick("*0x6bd3ef",,FoundX, FoundY)
Das ist natürlich BGR statt RGB. 0xefd36b is nämlich Beige auf BGR. Möglicherweise spinne ich, aber das könnte klappen.

Grüße,
burque505
nacken012
Posts: 90
Joined: 22 Jul 2016, 14:39

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

09 Apr 2020, 00:25

Vielen Dank, ja das klappt, aber hier noch 1 Frage, die normale Pixelsuche sucht ja von oben links nach unten rechts
und findet den ersten Baum wie oben im Bild.

FindClick findet aber nicht den Baum, sondern 2 weiter links den
burque505
Posts: 1731
Joined: 22 Jan 2017, 19:37

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

09 Apr 2020, 09:58

Hmm. Vielleicht kannste mit Folgendem experimentieren (siehe FindClick.ahk ca. 150)

Code: Select all

				d               Direction Of Search
				What to give    Left|Right|Bottom
				Description     This setting attempts to emulate the mode of pixelsearch where you can search from right to left or top to bottom – for instance, specifying Bottom will find the image closest to the bottom of the search area. However, to accomplish this the script needs to first find every image and then choose the coordinate pair that is furthest in the requested direction, making it a time-consuming process.
oder versuch's mal mit Bild statt Pixel, wie z.B mit dem Folgenden, was sich, soweit ich das beurteilen kann, nicht wiederholt:
baum1.PNG
baum1.PNG (3.38 KiB) Viewed 4266 times
Die Dokumentation für FindClick ist übrigens ziemlich umfassend (nur in englischer Sprache insofern ich weiss).
Grüße,
burque505
nacken012
Posts: 90
Joined: 22 Jul 2016, 14:39

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

09 Apr 2020, 17:53

Werde damit mal experimentieren.

Als Bildersuche geht leider nicht, da es unterschiedliche Untergründe sind und es man nicht weiß, wo welcher User die hinstellt.

Habe mir gleich mal nen kleines Programm geschrieben was aus RGB --> BGR macht und ins Clipboard kopiert :-)

Danke für Deine Mühe, werde berichten wenn ich erfolg hatte
burque505
Posts: 1731
Joined: 22 Jan 2017, 19:37

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

09 Apr 2020, 18:10

Danke, @nacken012, bitte sag mir Bescheid wenn's Dir gelingt.
gregster
Posts: 8886
Joined: 30 Sep 2013, 06:48

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

09 Apr 2020, 18:17

nacken012 wrote:
09 Apr 2020, 17:53
Danke für Deine Mühe, werde berichten wenn ich erfolg hatte
Sure, report away :) . But from now on, please in english on this topic here, or in the german language forum.
reverberation
Posts: 314
Joined: 13 Dec 2015, 20:48

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

09 May 2020, 00:07

Hi there,

how do I code it if I want to search for a "Reminder" image that only has BNW color (in Evernote)? does it have OCR?

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

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

11 May 2020, 20:59

reverberation wrote:
09 May 2020, 00:07
how do I code it if I want to search for a "Reminder" image that only has BNW color (in Evernote)? does it have OCR?
FindClick() is not an OCR app. It can help you capture the image that you would be searching for (although it looks like you've already captured it -- but you'll need to crop it around just the "Reminders" part that you're looking to find), and then you can use the FindClick() function to search for that image on the screen. Basically, it's an alternative to using the ImageSearch command directly (plus additional features).

Not sure what you mean by "BNW color." Does that mean black and white? Searching for black and white images is generally no different than any other images.

The best thing to do understand how to use this function is to check out the FindClick() documentation, then ask specific questions if you get stuck.
reverberation
Posts: 314
Joined: 13 Dec 2015, 20:48

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

15 May 2020, 01:08

Thanks for the explanation. Would like to check: if I have 4 PCs with different resolutions (1080p, 1440p, 3K, 4K), is it possible to use just ONE image (sampled from 4K) to FindClick instead of having 4 images? How do I go about optimizing this for all PCs?
User avatar
boiler
Posts: 16706
Joined: 21 Dec 2014, 02:44

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

15 May 2020, 02:22

It would be fine except I’m guessing that your machines that are running at higher resolutions have a Windows scaling factor of greater than 100%. Usually it’s OK up to about 150%, but at higher than that, Windows doesn’t display images with their true pixel-for-pixel representation, even though they look the same to the naked eye. It stretches the image so it’s made up of a bunch of interpolated/sampled pixel colors, which ImageSearch doesn’t have a chance of finding using the original source image as reference unless it has a small area of a unique color that can be found with enough allowable variance. The displayed image is often not even repeatable on the same computer in these situations, especially if it’s displayed in a different location.

Depending on the image, you can still find it if you carefully sample some pixel colors and take the average of those colors, and some functions have been written that do that.
User avatar
berban
Posts: 97
Joined: 14 Apr 2014, 03:20

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

15 May 2020, 16:53

Hey! Sorry I've been away from AutoHotkey for a while, but thank you so much to all of those who have been answering questions on here, you guys are the best!

boiler is right, usually Windows will automatically apply a scaling factor without telling you. In many applications (though not all) this will cause the images to become stretched and they likely wouldn't work with imagesearch with different scaling factors. You'll probably have to create a different image for each of the scaling factors that you are using (e.g. 100%, 125%, etc) which is unfortunately a pain.
boiler wrote:
15 May 2020, 02:22
Depending on the image, you can still find it if you carefully sample some pixel colors and take the average of those colors, and some functions have been written that do that.
This is another option for dealing with stretched images and I wanted to address this because I think I was working on something to this effect a while ago... but I don't believe I ever uploaded it to the forums :shifty: This is the WIP-version of the script that I have on my PC, if you select multiple pixels it will display the average value of the pixels and the degree of variation in the "Color" box (where it shows 0xF4F4F4 ~3 below). So in this instance, you should be able to successfully be able to locate the selected region with FindClick("*0xF4F4F4 5x6", "o3") (I'd like to have it spit that code out for you but hadn't gotten that far yet.)
Image

I'll try to upload that update as I had forgotten I'd never finished it, and I think it could be helpful to some.
hasantr
Posts: 933
Joined: 05 Apr 2016, 14:18
Location: İstanbul

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

16 May 2020, 03:03

berban wrote:
15 May 2020, 16:53
Hey! Sorry I've been away from AutoHotkey for a while, but thank you so much to all of those who have been answering questions on here, you guys are the best!

boiler is right, usually Windows will automatically apply a scaling factor without telling you. In many applications (though not all) this will cause the images to become stretched and they likely wouldn't work with imagesearch with different scaling factors. You'll probably have to create a different image for each of the scaling factors that you are using (e.g. 100%, 125%, etc) which is unfortunately a pain.
boiler wrote:
15 May 2020, 02:22
Depending on the image, you can still find it if you carefully sample some pixel colors and take the average of those colors, and some functions have been written that do that.
This is another option for dealing with stretched images and I wanted to address this because I think I was working on something to this effect a while ago... but I don't believe I ever uploaded it to the forums :shifty: This is the WIP-version of the script that I have on my PC, if you select multiple pixels it will display the average value of the pixels and the degree of variation in the "Color" box (where it shows 0xF4F4F4 ~3 below). So in this instance, you should be able to successfully be able to locate the selected region with FindClick("*0xF4F4F4 5x6", "o3") (I'd like to have it spit that code out for you but hadn't gotten that far yet.)
Image

I'll try to upload that update as I had forgotten I'd never finished it, and I think it could be helpful to some.
This would be great. I thought of doing the same thing, but I failed because I was a novice yet.
reverberation
Posts: 314
Joined: 13 Dec 2015, 20:48

Re: FindClick() - ImageSearch, Clicking, & More [Newest Version]

17 May 2020, 22:21

boiler wrote:
15 May 2020, 02:22
It would be fine except I’m guessing that your machines that are running at higher resolutions have a Windows scaling factor of greater than 100%. Usually it’s OK up to about 150%, but at higher than that, Windows doesn’t display images with their true pixel-for-pixel representation, even though they look the same to the naked eye. It stretches the image so it’s made up of a bunch of interpolated/sampled pixel colors, which ImageSearch doesn’t have a chance of finding using the original source image as reference unless it has a small area of a unique color that can be found with enough allowable variance. The displayed image is often not even repeatable on the same computer in these situations, especially if it’s displayed in a different location.

Depending on the image, you can still find it if you carefully sample some pixel colors and take the average of those colors, and some functions have been written that do that.
You're absolutely correct. My 4K screen is using a scaling factor or 250%.

Will you or anyone else be so kind as to guide me on how to code this step by step using FindClick please?

One of the sample images is the reminder icon in Evernote, which I guess is plain and not an outstanding color (like green), and thus will be impossible to make it work across different resolution screens?

Image

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: inseption86 and 80 guests