boat_58 Posted June 29, 2019 Share Posted June 29, 2019 For $n = 1 to 10 MouseClick("left",422,183); Open sleep(15000); Pause for 15 seconds For $n = 1 to 2 MouseClickDrag($MOUSE_CLICK_LEFT, 362, 384, 436, 384) sleep(1000); Pause for 1 seconds MouseClick("left",1585,205); 1 sleep(1000); Pause for 1 seconds MouseClick("left",1341,205); Click sleep(1000); Pause for 1 seconds MouseClick("left",1341,205); Click sleep(10000); Pause for 10 seconds Next MouseClick("left",1442,941); Close sleep(2000); Pause for 2 seconds Next I need the above code to test a program i want to create but so far its not working. I want it to Open the program, then do a series of clicks two times as indicated by middle For loop, then i need it to close the program and rest for 2 seconds. Then start all over again and do this for a total of 10 times as indicated by the main For loop. So far what happens is that everything runs 1 time, and doesn't do the remaining 9 times. Can anyone help me fix it? Link to comment Share on other sites More sharing options...
FrancescoDiMuro Posted June 29, 2019 Share Posted June 29, 2019 @boat_58 Use a different counter. Instead of $n, use $m, or the classic $i and $j. Add some ConsoleWrite() in each For so you can see what's going on. By the way, Mouse* functions are not the best solution to automate things. If you tell us what you are trying to automate, there could be a better solution that fits your needs Sidley 1 Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Link to comment Share on other sites More sharing options...
Sidley Posted July 2, 2019 Share Posted July 2, 2019 Francesco is correct. Look at the output from this modified script: For $n = 1 to 10 MouseClick("left",422,183); Open sleep(5000); Pause for 15 seconds For $n = 1 to 2 MouseClickDrag($MOUSE_CLICK_LEFT, 362, 384, 436, 384) sleep(1000); Pause for 1 seconds MouseClick("left",1585,205); 1 sleep(1000); Pause for 1 seconds MouseClick("left",1341,205); Click sleep(1000); Pause for 1 seconds MouseClick("left",1341,205); Click sleep(1000); Pause for 10 seconds ConsoleWrite("End loop 2: $n = " & $n & @CRLF) Next MouseClick("left",1442,941); Close sleep(2000); Pause for 2 seconds ConsoleWrite("End loop 1: $n = " & $n & @CRLF) Next It's creating an infinite loop because every time it enters the second loop, it resets $m to 1. Use two separate variables for nested loops to avoid this. Link to comment Share on other sites More sharing options...
boat_58 Posted July 6, 2019 Author Share Posted July 6, 2019 Thank you 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