Jump to content

Recommended Posts

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
Posted

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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...