Automatic reload of the script stops the execution of the hotkey.

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Rostov
Posts: 129
Joined: 09 Apr 2020, 07:57

Automatic reload of the script stops the execution of the hotkey.

Post by Rostov » 24 Jan 2021, 16:28

I am using the following code to automatically reload my ahk script every 5 minutes:

Code: Select all

#Persistent

SetTimer, offAndOnAgain, 300000

return

offAndOnAgain:

Reload
return
It works very well. But sometimes, when it is time to automatically reload the script, I am in the process of using a hotkey, the execution of which takes e.g. a few seconds. Then reloading the script stops the execution of the hotkey.

Is it possible that when the script reload time is when a hotkey is being executed, the script reloading will be delayed until the hotkey is executed? In such a way that the automatic reloading of the script does not stop the execution of the hotkey.
braunbaer
Posts: 478
Joined: 22 Feb 2016, 10:49

Re: Automatic reload of the script stops the execution of the hotkey.

Post by braunbaer » 24 Jan 2021, 16:45

A_TimeIdle
A_TimeIdlePhysical

By the way, what is the idea behind reloading the script all the time?
Rostov
Posts: 129
Joined: 09 Apr 2020, 07:57

Re: Automatic reload of the script stops the execution of the hotkey.

Post by Rostov » 24 Jan 2021, 16:55

@braunbaer, where should I put the values you provided?

In one ahk script I have dozens of hotkeys. Occasionally the script gets stuck. Automatic script reloading is to prevent such jamming of the script in the least expected moment of work.
braunbaer
Posts: 478
Joined: 22 Feb 2016, 10:49

Re: Automatic reload of the script stops the execution of the hotkey.

Post by braunbaer » 27 Jan 2021, 07:38

What do you mean with "jamming"?

And what do you mean with "gets stuck". If something gets stuck, there must be a mistake somewhere in the script that you better should better find and correct instead of building such a workaround.

But if you insist in doing it that way, look for the command "Thread". You can make your hotkey threads uninterruptible by timers.
Rostov
Posts: 129
Joined: 09 Apr 2020, 07:57

Re: Automatic reload of the script stops the execution of the hotkey.

Post by Rostov » 27 Jan 2021, 13:58

@braunbaer, sorry, my english isn't very good so I use Google Translate. For this reason, these differences in terms. I meant that at some point my hotkeys stop working and I need to reload the script for them to start working again.

I have one more question.
Does the command 'Thread, NoTimers, True' reset the timer or does it stop the countdown until the hotkey is finished?
braunbaer
Posts: 478
Joined: 22 Feb 2016, 10:49

Re: Automatic reload of the script stops the execution of the hotkey.

Post by braunbaer » 28 Jan 2021, 10:04

The documentation is not clear about what happens in such a situation. It certainly does not stop the countdown. I suppose the timer routines are executed as soon as the uninterruptible thread finishes, but I am not sure.

BTW, I really would discourage making a periodic reload of the script. Rather a manual reload (I use #+r in my script for that) if something has gone wrong... And then find out what has gone wrong and correct the error...
Post Reply

Return to “Ask for Help (v1)”