Pixelsearch to MIN

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Dobbythenerd1
Posts: 10
Joined: 14 Apr 2024, 02:55

Pixelsearch to MIN

15 May 2024, 03:36

Hello everyone, I am trying to pixelsearch for the top left of a box but the color varies a lot. The normal variation of pixelsearch does not work for this due to such big differences so i tried doing multiple pixel searches and then MIN the X and Y but i can't get it to work. Can anyone see whats going wrong with my code? Ignore the color, im writing this as an example.

Code: Select all

Pixelsearch, Colx1, Coly1, 10, 10, 1000, 1000, Color, 5, Fast
Pixelsearch, Colx2, Coly2, 10, 10, 1000, 1000, Color, 5, Fast
Pixelsearch, Colx3, Coly3, 10, 10, 1000, 1000, Color, 5, Fast
X:= Min(Colx1,Colx2,Colx3)
Y:= Min(Coly1,Coly2, Coly3)

Msgbox, %X%,%Y%
Mousemove, X, Y
The msgbox is blank and no mouse movement. I cant figure out how to get the X and Y coords of each color into the mins. If there is a more efficient way of doing it please advice also. Thanks.
Dobbythenerd1
Posts: 10
Joined: 14 Apr 2024, 02:55

Re: Pixelsearch to MIN

15 May 2024, 03:49

Forgot to mention. I believe its because the Pixelsearch variable is VARREF? Can this not be used with min?
User avatar
boiler
Posts: 17242
Joined: 21 Dec 2014, 02:44

Re: Pixelsearch to MIN

15 May 2024, 06:29

You can’t use Min if not all the colors were found. If any of the parameters are non-numeric (blank, in this case), it returns an empty string, per the documentation. You need to only include the numeric values, which can done by adding them to an array if they are not blank, like this:

Code: Select all

Colx := []
Coly := []
Pixelsearch, Colx1, Coly1, 10, 10, 1000, 1000, Color, 5, Fast
Pixelsearch, Colx2, Coly2, 10, 10, 1000, 1000, Color, 5, Fast
Pixelsearch, Colx3, Coly3, 10, 10, 1000, 1000, Color, 5, Fast
loop, 3 {
	if (Colx%A_Index% != "")
		Colx.Push(Colx%A_Index%)
	if (Coly%A_Index% != "")
		Coly.Push(Coly%A_Index%)
}
X:= Min(Colx*)
Y:= Min(Coly*)
Msgbox, %X%,%Y%
Mousemove, X, Y
Dobbythenerd1
Posts: 10
Joined: 14 Apr 2024, 02:55

Re: Pixelsearch to MIN

15 May 2024, 08:22

Thanks for the help boiler. It's taken me a good 10 minutes to understand it but i think i get it now. Arrays is my next area of learning. I have just been using loads of Variables. Thanks again

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: pgeugene, songdg and 80 guests