Jump to content
Sign in to follow this  

Calling a function with a single func as the parameter

Recommended Posts


If I want to call a function that takes multiple parameters, like pixelsearch, for instance, Autoit expects me to have something in the format of pixelsearch(x,y,x,y,color).

Could I do this with fewer parameters by using another function? My code looks something like this:



func box($iX,$iY)

return ($iX-10&","&$iY-10&","&$iX+10&","&$iY+10)


Clearly, this will only return one result, but it really contains enough data to fill in 4 of the 5 required parameters for pixelsearch. What I want to do is this:


But it thinks I have too few parameters. Is there a way to 'tell' autoit to treat one parameter as multiple parameters? If not, how can I get around this simply?


Edited by branwall

Share this post

Link to post
Share on other sites

Well, you can define your own function with less parameters and internaly calculate the others parameters, like in this example:



$Pixel = PixelSearchInBox($x,$y,0xFFFFFF)    ;Search for white color in a box 20x20 start from 0,0 to 20,20
If IsArray($Pixel) Then
    MsgBox(0,"",$Pixel[0] & "x" & $Pixel[1])
    MsgBox(0x10,"Error","Pixel not found")

Func PixelSearchInBox($x,$y,$iColor,$size=10)
    Return PixelSearch($x-$size,$y-$size,$x+$size,$y+$size,$iColor)

When the words fail... music speaks

Share this post

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
Sign in to follow this