Sign in to follow this  
Followers 0
branwall

Calling a function with a single func as the parameter

2 posts in this topic

#1 ·  Posted (edited)

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:

$x=10

$y=10

func box($iX,$iY)

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

endfunc

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:

pixelsearch(box($X,$Y),$Color)

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?

Thanks!

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:

$x=10
$y=10

Sleep(3000)

$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])
Else
    MsgBox(0x10,"Error","Pixel not found")
EndIf

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

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  
Followers 0