Stops Working - Need to Reload Script

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
js0873
Posts: 21
Joined: 07 Mar 2019, 08:47

Stops Working - Need to Reload Script

Post by js0873 » 09 Aug 2022, 07:27

Most AHK works fine, but at times, maybe every other day, it just quits working. I can get it going again just by reloading the script. I have no idea what cause me to need to do that. But I put the following it from a suggestion way back:

Code: Select all

#Persistent
SetTimer, offAndOnAgain, 60000
return

offAndOnAgain:
Reload
return
And that's not working either. I can't recall what the 60000 represents. Is it milliseconds? But in any case, what's the best way to either prevent this from happening, or to routinely reload the script every so often?

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

Re: Stops Working - Need to Reload Script

Post by RussF » 09 Aug 2022, 08:09

Sometimes scripts appear to be "hung up" because they are waiting for some event that never happens. They are actually still running, but because of code that doesn't anticipate every possible scenario, they just sit and wait.

Without seeing the actual script, no one will be able to help you troubleshoot.

Russ

js0873
Posts: 21
Joined: 07 Mar 2019, 08:47

Re: Stops Working - Need to Reload Script

Post by js0873 » 09 Aug 2022, 08:36

Here's the entire script, as simple as it is:

Code: Select all

::eee::[email protected]
::found@::The Foundation
::qq::leef2022
::q::leef2022
::cr::Your request has been added to the calendar.

::pk::You have a package at the reception desk.

::cert:: Cannon Certificate(s) of Attendance


#Persistent

SetTimer, offAndOnAgain, 60000

return

offAndOnAgain:

Reload
return

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

Re: Stops Working - Need to Reload Script

Post by RussF » 09 Aug 2022, 08:59

I have no idea why the original script (without the reload timer) was failing for you. I couldn't get it to fail.

The reason the addition of the timer portion failed was the location in the script that you inserted it. Scripts start processing at the top and stop as soon as a hotkey or hotstring is reached. Any code after that is unreachable unless it it a function or subroutine that is called by another part of the program. You put all the timer code after your hotstring definitions and they were therefore unreachable. See the Auto-execute section of the documentation.

Try this - the timer should reload the script every 60 seconds (although I'm still not sure why you need it.)

Code: Select all

#Persistent
SetTimer, offAndOnAgain, 60000
return

offAndOnAgain:
    Reload
return

::eee::[email protected]
::found@::The Foundation
::qq::leef2022
::q::leef2022
::cr::Your request has been added to the calendar.
::pk::You have a package at the reception desk.
::cert:: Cannon Certificate(s) of Attendance
Russ

js0873
Posts: 21
Joined: 07 Mar 2019, 08:47

Re: Stops Working - Need to Reload Script

Post by js0873 » 09 Aug 2022, 10:30

Thanks. I'm trying that out now.

swagfag
Posts: 6222
Joined: 11 Jan 2017, 17:59

Re: Stops Working - Need to Reload Script

Post by swagfag » 09 Aug 2022, 19:01

u probably have some other application running that's overriding the keyboard hook, so ur hotstrings stop working. u need to figure out which application does that and quit it(if possible). if not possible, ull be forced to perpetually suspend/unsuspend ur ahk script, so that it overrides the hook

js0873
Posts: 21
Joined: 07 Mar 2019, 08:47

Re: Stops Working - Need to Reload Script

Post by js0873 » 10 Aug 2022, 07:53

u probably have some other application running that's overriding the keyboard hook
How would I go about figuring out what that application might be?

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

Re: Stops Working - Need to Reload Script

Post by RussF » 10 Aug 2022, 08:15

The first and easiest thing to do would just to be observant. You say that it works for a day or so then just quits. Make a note of the last programs you ran just before the script stopped working. Then start intentional testing with those apps.

Russ

Post Reply

Return to “Ask for Help (v1)”