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

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Rieschiek
Posts: 15
Joined: 01 Dec 2022, 15:39

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

Post by Rieschiek » 09 Dec 2022, 11:42

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

User avatar
mikeyww
Posts: 26953
Joined: 09 Sep 2014, 18:38

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

Post by mikeyww » 09 Dec 2022, 12:54

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.

Rieschiek
Posts: 15
Joined: 01 Dec 2022, 15:39

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

Post by Rieschiek » 09 Dec 2022, 14:28

Thanks maybe it is using too much CPU and stops working.

Post Reply

Return to “Ask for Help (v1)”