Page 1 of 1

Mouse Keeps Getting Stuck Frozen if I add more lines in the loop

Posted: 09 Dec 2022, 11:42
by Rieschiek
Hello, sometimes the following script will make my mouse stop working. Left click still works but unable to move the mouse and this makes the script stop moving the mouse. I can't seem to figure out why. Sometimes the mouse gets stop on the top left corner of the screen as well.

Code: Select all

TH:
WinGetPos, wx, wy, ww, wh, ProgramName -
if (ok:=FindText(X, Y, wx, wy, wx+ww, wy+wh, 0.000001, 0.000001, TextFindsPuzzle,,0)){
	Loop{

		if (ok:=FindText(X, Y, wx, wy, wx+ww, wy+wh, 0.000001, 0.000001, TextPuzzleSolve)){
			Random, i, 1, % ok.MaxIndex()
			Random, xx, -5, 5
			Random, yy, -5, 5
			sleep_click(ok[i].x+xx, ok[i].y+yy)
		}
		
		
		if (ok:=FindText(X, Y, wx, wy, wx+ww, wy+wh, 0.000001, 0.000001, TextPuzzlePiece1)){
			Random, i, 1, % ok.MaxIndex()
			Random, xx, -5, 5
			Random, yy, -5, 5
			sleep_click(ok[i].x+xx, ok[i].y+yy)
		}
		
		if (ok:=FindText(X, Y, wx, wy, wx+ww, wy+wh, 0.000001, 0.000001, TextFindsPuzzle)){
			Random, i, 1, % ok.MaxIndex()
			Random, xx, -5, 5
			Random, yy, -5, 5
			sleep_click(ok[i].x+xx, ok[i].y+yy)
		}
		if (ok:=FindText(X, Y, wx, wy, wx+ww, wy+wh, 0.000001, 0.000001, TextPuzzleInactive)){ 
	if (ok:=FindText(X, Y, wx, wy, wx+ww, wy+wh, 0.000001, 0.000001, TextLeavePuzzle)){ 
         Random, xx, -3, 3
         Random, yy, -3, 3
         sleep_click(ok[1].x+xx, ok[1].y+yy)
		 sleep, rand_range(2000, 5000)
      }
	}

}
}
return

Re: Mouse Keeps Getting Stuck Frozen if I add more lines in the loop  Topic is solved

Posted: 09 Dec 2022, 12:54
by mikeyww
A few possible reasons why a mouse might not move:
1. Other process is moving the mouse elsewhere
2. Active window is elevated
3. Mouse movement is actively being blocked
4. Mouse is broken
5. CPU is consumed with other activities

In the case of your script, identifying the offending line is simple: eliminate lines until you eliminate the problem. You then have your answer. Estimated time required: 5 minutes.

Re: Mouse Keeps Getting Stuck Frozen if I add more lines in the loop

Posted: 09 Dec 2022, 14:28
by Rieschiek
Thanks maybe it is using too much CPU and stops working.