JonJablonowski Posted May 16, 2024 Posted May 16, 2024 (edited) I'm trying to have an auto clicker where I save x,y positions and have potential text (like click counter) as well as time between clicks (4 parameters). I'm saving the clicks in an array but can't get the function to work Local $aClicks[3][4] = [[100, 100, "Test", 1000] _ , [200, 200, " Test2", 1500] _ , [200, 200, " Test3", 2000]] Clicking($aClicks) With Clicking being this function Func Clicking($x, $y, $s = "", $z = 1000) But I'm constantly getting an error pointing to "Clicking($aClicks)" and saying Error: Incorrect number of parameters in function call. If I write this instead it works Local $aClicks[3][2] = [[100, 100] _ , [200, 200] _ , [200, 200]] Clicking($aClicks, "Test", 1000) But then I only get the X and Y pos. I just don't understand how the first case is giving me errors, given the array is given 4 parameters to each element, which the function requires. Edited May 16, 2024 by JonJablonowski I'm new to all this so excuse my beginner questions 😕
Solution Andreik Posted May 16, 2024 Solution Posted May 16, 2024 (edited) 21 minutes ago, JonJablonowski said: Local $aClicks[3][4] = [[100, 100, "Test", 1000] _ , [200, 200, " Test2", 1500] _ , [200, 200, " Test3", 2000]] Clicking($aClicks) With Clicking being this function Func Clicking($x, $y, $s = "", $z = 1000) But I'm constantly getting an error pointing to "Clicking($aClicks)" and saying Error: Incorrect number of parameters in function call. In first example you are calling Clicking with a single parameter and below your function has at least 2 mandatory parameters ($x, $y) out of 4 parameters. Isn't this self explanatory? If you want to use the first example then your function should look like this: Local $aClicks[3][4] = [[100, 100, "Test", 1000] _ , [200, 200, " Test2", 1500] _ , [200, 200, " Test3", 2000]] Clicking($aClicks) Func Clicking($aClicks) ; Your code here EndFunc Or if you want to preserve your original function with 4 parameters you can do something like this: Local $aClicks[3][4] = [[100, 100, "Test", 1000] _ , [200, 200, " Test2", 1500] _ , [200, 200, " Test3", 2000]] ClickingArray($aClicks) Func ClickingArray($aClicks) For $Index = 0 To UBound($aClicks) - 1 Clicking($aClicks[$Index][0], $aClicks[$Index][1], $aClicks[$Index][2], $aClicks[$Index][3]) Next EndFunc Func Clicking($x, $y, $s = "", $z = 1000) ; Your original function EndFunc Edited May 16, 2024 by Andreik JonJablonowski 1
JonJablonowski Posted May 16, 2024 Author Posted May 16, 2024 It's not. I'm obviously wrong since it's not working but the way I read it is that in the first case I'm providing 4 parameters (the two mandatory ones and the 2 optional ones) while in the second case I'm only giving the 2 mandatory ones and leave the optional ones as default. I'm very new to this so I'm trying to wrap my head around things. I'm new to all this so excuse my beginner questions 😕
Andreik Posted May 16, 2024 Posted May 16, 2024 2 minutes ago, JonJablonowski said: in the first case I'm providing 4 parameters (the two mandatory ones and the 2 optional ones) while in the second case I'm only giving the 2 mandatory ones and leave the optional ones as default. 18 minutes ago, JonJablonowski said: Local $aClicks[3][4] = [[100, 100, "Test", 1000] _ , [200, 200, " Test2", 1500] _ , [200, 200, " Test3", 2000]] Clicking($aClicks) I see a single parameter here ($aClicks). Where is the second parameter?
JonJablonowski Posted May 16, 2024 Author Posted May 16, 2024 Just now, Andreik said: I see a single parameter here ($aClicks). Where is the second parameter? But isn't $aClicks made up of [100, 100, "Test", 1000] which is 4 parameters? I'm new to all this so excuse my beginner questions 😕
Andreik Posted May 16, 2024 Posted May 16, 2024 No. These are dimensions of an array not arguments of a function. JonJablonowski 1
JonJablonowski Posted May 16, 2024 Author Posted May 16, 2024 Ok, sounds like this is way out of my league and I'll go back to simpler things for now. Thanks for helping out! I'm new to all this so excuse my beginner questions 😕
Andreik Posted May 16, 2024 Posted May 16, 2024 (edited) It's kinda simple. All arguments of a function are separated by a comma. Even if a variable is an array and contains multiple data it doesn't mean that when this variable it's passed to a function it takes up more than a single parameter. See example below: $Int = 48 $String = "This is a test" Dim $Array[3] = ["I can hold multiple data", "But I am a single variable", "And I am passed as a single parameter to a function"] Test($Int, $String, $Array) Func Test($Param1, $Param2, $Param3) ConsoleWrite(VarGetType($Param1) & @CRLF) ConsoleWrite(VarGetType($Param2) & @CRLF) ConsoleWrite(VarGetType($Param3) & @CRLF) EndFunc Edited May 16, 2024 by Andreik JonJablonowski 1
JonJablonowski Posted May 17, 2024 Author Posted May 17, 2024 Thanks! That clears it up in my head. Much love! I'm new to all this so excuse my beginner questions 😕
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now