boat_58 0 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? Share this post Link to post Share on other sites
FrancescoDiMuro 424 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 1 Sidley reacted to this Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette Share this post Link to post Share on other sites
Sidley 18 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. Share this post Link to post Share on other sites