darksoltan Posted January 18, 2012 Share Posted January 18, 2012 newbY Round 2. So I'm trying to get this array Click[$n]() to use a specific function command depending on the value of [$n], but I guess that's not how it's designed to work. Any ideas? Here's my code: $Click = "Click1(),Click2(),Click3()" Dim $Split[3] $Split = StringSplit($Click,",") For $n = 1 to 3 sleep(1000) Click[$n] Next Func Click1() MouseClick("left", 858, 500) EndFunc Func Click2() MouseClick("left", 858, 550) EndFunc Func Click3() MouseClick("left", 858, 600) EndFunc Link to comment Share on other sites More sharing options...
RichardL Posted January 18, 2012 Share Posted January 18, 2012 darksoltan, Look at the help on 'Call'. I've not needed to do this, but I think it does what you want. Richard. Link to comment Share on other sites More sharing options...
lark Posted January 18, 2012 Share Posted January 18, 2012 (edited) This largely depends on what you want it to do, but here are some possible answers: Just have one function, and have a parameter- so it would be like Func Click($n) MouseClick("left", 858, 500 + (50 * $n)) EndFunc This doesn't use the arrays at all, but I don't know if your goal was to figure out a way to use the arrays to do this, or maybe you were just trying to figure out another way to run the function there. But if you did want to be able to use arrays to do this, what RichardL said about the call function should work. I haven't had to use that before either, but looking in the helpfile, hopefully this might work: For $n = 0 To 2 Step 1 Sleep(1000) Call($Click[$n]) Next Hope it helped Edit: using the 'call' method didn't work when I tried it in scite, but just laying out the $Click array made it work. Maybe I did something wrong and accidentally changed something in one of the functions, but here is a quick copy and paste from what did make it work: Global $Click[3] $Click[0] = "Click1" $Click[1] = "Click2" $Click[2] = "Click3" Edited January 18, 2012 by mischieftoo Link to comment Share on other sites More sharing options...
darksoltan Posted January 18, 2012 Author Share Posted January 18, 2012 Hey Guys, Thx! The "Call" did the trick. But now I've run into another problem, I can't put it into a Do Until or While 1 Wend loop. How can I loop this:For $n = 0 To 2 Step 1 Sleep(1000) Call($Click[$n]) NextAlso, what I have so far:HotKeySet("{ESC}" , "quit") Global $Click[3] $Click[0] = Click1() $Click[1] = Click2() $Click[2] = Click3() For $n = 0 To 2 Step 1 Sleep(1000) Call($Click[$n]) Next Func Click1() MouseClick("left", 858, 400) EndFunc Func Click2() MouseClick("left", 858, 650) EndFunc Func Click3() MouseClick("left", 858, 200) EndFunc Func quit() Exit 1 EndFunc Link to comment Share on other sites More sharing options...
lark Posted January 18, 2012 Share Posted January 18, 2012 You could try: Global $n = 0 While 1 Sleep(1000) Call($Click[$n]) $n += 1 If $n = 3 Then $n = 0 WEnd and a do until loop: Global $n = 0 Do Sleep(1000) Call($Click[$n]) $n += 1 Until $n = 3 Link to comment Share on other sites More sharing options...
darksoltan Posted January 18, 2012 Author Share Posted January 18, 2012 Well, back to the drawing board. The Call command doesn't really work, and that's why I couldn't get it to loop.Newb mistake but defining the Clicks[0] made the mouse move&click and not the Call line. DOH :/This:Global $Click[3] $Click[0] = "Click1" $Click[1] = "Click2" $Click[2] = "Click3"The answer might be the Call command, going to check it out more tomorrow. time for sleep Link to comment Share on other sites More sharing options...
lark Posted January 18, 2012 Share Posted January 18, 2012 I'm not sure what your referring to, but i think you are saying that typing out Clicks[0] is going to make the mouse click? The regular functions use the pathentesis ( ) to fill in parameters, not the brackets [ ]. But i dont get what you were saying, because when i ran it as i posted, scite showed no errors? It should be working fine. But when you said the call command doesnt really work, could you explain? It might be that you defined the strings with the parenthesis at the end, which i think you did earlier up there; that might be the cause of an error. Meaning, instead of "click1()" Use "click1" Link to comment Share on other sites More sharing options...
lark Posted January 18, 2012 Share Posted January 18, 2012 I'm not sure what your referring to, but i think you are saying that typing out Clicks[0] is going to make the mouse click? The regular functions use the pathentesis ( ) to fill in parameters, not the brackets [ ]. But i dont get what you were saying, because when i ran it as i posted, scite showed no errors? It should be working fine. But when you said the call command doesnt really work, could you explain? It might be that you defined the strings with the parenthesis at the end, which i think you did earlier up there; that might be the cause of an error. Meaning, instead of "click1()" Use "click1" Link to comment Share on other sites More sharing options...
bogQ Posted January 18, 2012 Share Posted January 18, 2012 if you need only mouse click this can helpHotKeySet('{ESC}','_exit') Dim $Split[3][2] = [[858, 500],[858, 550],[858, 600]] While 1 For $n = 0 to UBound($Split)-1 sleep(1000) MouseClick("left",$Split[$n][0],$Split[$n][1]) Next WEnd Func _exit() Exit EndFuncif you use mouseclick only as example and you need something else in your funcs then mischieftoo geaved you nice solutionHotKeySet('{ESC}','_exit') ;~ $Split = StringSplit("Click1,Click2,Click3",",") Dim $Split[3] = ['Click1','Click2','Click3'] While 1 For $n = 0 to UBound($Split)-1 sleep(1000) Call($Split[$n]) Next WEnd Func Click1() MouseClick("left", 858, 500) EndFunc Func Click2() MouseClick("left", 858, 550) EndFunc Func Click3() MouseClick("left", 858, 600) EndFunc Func _exit() Exit EndFunc TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost. Link to comment Share on other sites More sharing options...
darksoltan Posted January 18, 2012 Author Share Posted January 18, 2012 Thx bogQ for a working example! Now I understand the description for Call: "Calling a function in a string parameter." TY!! Link to comment Share on other sites More sharing options...
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