loop lag in a few hours Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
kentpachi
Posts: 152
Joined: 15 May 2016, 01:23

loop lag in a few hours

Post by kentpachi » 04 Aug 2023, 06:33

I have a script running a whole day but after a few hours maybe within 3hrs+

the script is totally lagging like really lag


this is the script

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#singleinstance, force
#MaxThreadsPerHotkey 2
loop
{
;sarn1

CoordMode, Pixel, Window
ImageSearch, FoundX, FoundY, 1410, 695, 1648, 908, *25 sarn1.png
If ErrorLevel = 0
{
	Click, %FoundX%, %FoundY% Left, 1
sleep, 2000

}


}






}
[Mod edit: Replaced c-tags with [code][/code] tags.]
[Mod edit: Moved topic to AHK v1 help, since this is not v2 code.]

RussF
Posts: 1311
Joined: 05 Aug 2021, 06:36

Re: loop lag in a few hours

Post by RussF » 04 Aug 2023, 07:05

There doesn't appear to be anything within your code that would cause it to lag, however, a few points:

1) You have posted V1 code in the V2 forum.
2) Please use code tags around your code, not kbd tags.
3) You have one too many closing curly braces.
4) You haven't indicated what it is that you are running this against. A game? A web site? If a web site, it could be the host server lagging, not your script.

Russ

kentpachi
Posts: 152
Joined: 15 May 2016, 01:23

Re: loop lag in a few hours

Post by kentpachi » 04 Aug 2023, 09:41

RussF wrote:
04 Aug 2023, 07:05
There doesn't appear to be anything within your code that would cause it to lag, however, a few points:

1) You have posted V1 code in the V2 forum.
2) Please use code tags around your code, not kbd tags.
3) You have one too many closing curly braces.
4) You haven't indicated what it is that you are running this against. A game? A web site? If a web site, it could be the host server lagging, not your script.

Russ
in a game, i notice my game was lagging, i tried closing the ahk and the lag was gone.

ok, ill try to remove braces and see if it helps.

User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: loop lag in a few hours  Topic is solved

Post by Xtra » 04 Aug 2023, 11:05

The loop only sleeps when the image is found.
It's using to much CPU when not found and lagging your game.
Try putting a small sleep in the loop: Sleep, 15 this will reduce cpu usage.
If you still have lag increase it to: Sleep, 50

Post Reply

Return to “Ask for Help (v1)”