Return's parameter error, even inside a function

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
pilger
Posts: 4
Joined: 01 Apr 2016, 13:27

Return's parameter error, even inside a function

01 Apr 2016, 13:31

Hey guys,

I have the following code (and that's all the code, really):

Code: Select all

WaitPixelColor (x, y, color, limit:=20)
{
	loop %limit%
	{

		Sleep, 500
		PixelGetColor, Color, %x%, %y%

		if (Color = %color%) {
			Return true
		}
	}
	Return false
}
I get a "Error: Return's parameter should be blank except inside a function." when I try to reload the script. Both returns seem to be inside the function. What could be going wrong here!?

Thanks in advance! :thumbup:
User avatar
TheDewd
Posts: 1513
Joined: 19 Dec 2013, 11:16
Location: USA

Re: Return's parameter error, even inside a function

01 Apr 2016, 13:51

Your function isn't being recognized because you've added a space between the name and the parameters:

WaitPixelColor (x, y, color, limit:=20)
Should be
WaitPixelColor(x, y, color, limit:=20)
Last edited by TheDewd on 01 Apr 2016, 13:52, edited 1 time in total.
pilger
Posts: 4
Joined: 01 Apr 2016, 13:27

Re: Return's parameter error, even inside a function

01 Apr 2016, 13:52

Thank you very much. That did the trick. Dumb mistake!
lexikos
Posts: 9690
Joined: 30 Sep 2013, 04:07
Contact:

Re: Return's parameter error, even inside a function

02 Apr 2016, 18:18

Maybe you figured it out after fixing the function definition, but...
if (Color = %color%)
I'm pretty sure this part isn't working as intended. My guess is that you made two mistakes:
  1. Color and color are intended to be two different variables, so you can compare the result of PixelGetColor to the original value of the parameter. However, variable names in AutoHotkey are not case-sensitive, so PixelGetColor is overwriting the parameter value.
  2. %color% is a double-deref. See FAQ: When exactly are variable names enclosed in percent signs?

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: bobstoner289, Chunjee, peter_ahk and 323 guests