Page 1 of 1

Windows 7 to Windows 10: Having to Reload Script

Posted: 07 Mar 2019, 08:52
by js0873
Since my recent conversion from Windows 7 to Windows 10 I'm finding that occasionally I'm having to reload my script to get my shortcuts running again. This happens maybe once a day or so. This never happened to me in Windows 7. Is there some fix for this? Do others have the same problem?

Re: Windows 7 to Windows 10: Having to Reload Script

Posted: 07 Mar 2019, 13:06
by sinkfaze
That's hard for us to determine if we can't see your script, can you share it?

Re: Windows 7 to Windows 10: Having to Reload Script

Posted: 08 Mar 2019, 08:21
by js0873
It's all very simple, just shortcuts. One had an asterisk in it by mistake (ggg), so I'm removing it, but here it is, with the actual simple text redacted after the shortcuts:

Code: Select all

::ojs::
::o3s::
::o3su::
::jss::
::acnu::
::acnpw::
::jsp::
::occfsc::
:*:ggg::
::eee::
::osc::
::occfsc::
::j.s::

::encryptemail::*** For your security this email and all of its attachments have been encrypted ***
::qqq::*** For your security this email and all of its attachments have been encrypted ***

Re: Windows 7 to Windows 10: Having to Reload Script

Posted: 11 Mar 2019, 07:58
by js0873
Does anyone have any ideas on this? Is there a workaround?

Re: Windows 7 to Windows 10: Having to Reload Script

Posted: 11 Mar 2019, 09:33
by sinkfaze
I can run those hotstrings on my Windows 10 machine without any issue. Are you running your script as administrator?

Re: Windows 7 to Windows 10: Having to Reload Script

Posted: 11 Mar 2019, 15:45
by js0873
Well, I'm a local admin on my machine. Keep in mind that these work work of the time, but I simply have to reload them at other times. So 95% of the time the script is fine, the other 5% I have to reload it.

Re: Windows 7 to Windows 10: Having to Reload Script

Posted: 11 Mar 2019, 17:52
by iPhilip
You might try putting a SendInput after the second pair of colons. You might also want to log their use so that you can see which hotstring is causing the problem.

Re: Windows 7 to Windows 10: Having to Reload Script

Posted: 20 Apr 2019, 10:04
by js0873
At this point I don't think it's a Windows 10 issue or a problem with any of my script. I have to believe some other program I'm running is conflicting with AutoHotkey, but I haven't isolated what it might be. It happens every few days or so and I have many machines and this is the only one it's happening with.

I guess what I'd like is simply something that would cause the reload script to happen, maybe every 30 minutes or so. If it's something I could run with task scheduler that would be fine too. Is there a way to issue the "Reload this Script" from a batch command? Any other ideas?

Re: Windows 7 to Windows 10: Having to Reload Script

Posted: 20 Apr 2019, 11:03
by Odlanir
You can put this at the end of your script

Code: Select all

min := 30*60
SetTimer, ReloadMe, 1000
return

ReloadMe:
    if (++cnt > Min)
        Reload
return

Re: Windows 7 to Windows 10: Having to Reload Script

Posted: 20 Apr 2019, 11:22
by js0873
Odlanir wrote:
20 Apr 2019, 11:03
You can put this at the end of your script

Code: Select all

min := 30*60
SetTimer, ReloadMe, 1000
return

ReloadMe:
    if (++cnt > Min)
        Reload
return
I'll put it in right now, and thanks. I obviously won't know if it fully works until some days have passed, but if it truly reloads every 30 minutes it should work.

Re: Windows 7 to Windows 10: Having to Reload Script

Posted: 20 Apr 2019, 11:34
by jeeswg
- Every so often, on Windows 7, I've experienced hotkeys being forgotten, and a reload being required. This can often be due to high CPU load.
- The script can Reload itself, or another script can reload it via a message, or perhaps you could put #SingleInstance force in the script and just reopen the script via the command line.
- To reload a script via a message:
list of AutoHotkey WM_COMMAND IDs (e.g. Reload/Edit/Suspend/ListVars on another script) - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=74&t=27824
- For me, the key thing of interest would be if there were a way to *check* if the hotkeys were sill active.

- [EDIT:] A problem with reloading is receiving the 'Could not close...' prompt, a workaround is to close and reopen a script.
avoid 'Could not close the previous instance of this script' warnings - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=6&t=59615

Re: Windows 7 to Windows 10: Having to Reload Script

Posted: 21 Apr 2019, 18:03
by lexikos
Check KeyHistory after the script stops recognizing hotstrings. If it has stopped recognizing keys, the problem will relate to the keyboard hook. Other programs with keyboard hooks can be one cause. The most recently installed keyboard hook takes precedence.

You can sometimes reinstall the keyboard hook by calling Suspend On followed by Suspend Off, but it won't work if any hotkeys are Suspend-exempt or the hook is required for some other reason, such as #InstallKeybdHook.

I would suggest setting the LowLevelHooksTimeout registry value to a high value for testing (e.g. 1000; 1 second is an excessively long time to process a single keyboard event). If the hook frequently encounters the system timeout, it may be silently disabled by the system. See #IfTimeout for details (but the directive itself is no use here).

Re: Windows 7 to Windows 10: Having to Reload Script

Posted: 22 Apr 2019, 01:11
by 1100++
Did you use EnableUIAccess on an executable other than AutoHotkey?

Re: Windows 7 to Windows 10: Having to Reload Script

Posted: 22 Apr 2019, 11:53
by js0873
Let me give an update. The reload script didn't seem to help. Yesterday I had to reload my script and again today to get things working again.

I'm not sure how to check KeyHistory. The next time it happens I'll try just suspending and turning that off again to see if that allows it to work, vs. a reload.

Here's my impressions: I don't recall this ever happening, AHK not working, once I'm actively using my machine. It only seems to occur once my display has been locked after inactivity, and not every time, but occasionally.

I did install a mouse movement utility a month or so ago, one that initiates a task if the mouse hasn't been moved for 75 minutes in my case. That shouldn't be keyboard related but just to knock that out I've disabled that for now.

Last, I don't know how to use EnableUIAccess on an executable. How would that be done?

Re: Windows 7 to Windows 10: Having to Reload Script

Posted: 22 Apr 2019, 21:28
by SuperFoobar
The problem might be no admin access. Right click the AHK exe in program files, and check :Run as admin: in the compatibility tab

Re: Windows 7 to Windows 10: Having to Reload Script

Posted: 23 Apr 2019, 04:34
by lexikos
As general advice, I would recommend not changing the compatibility settings of AutoHotkey.exe. Instead, try the workarounds listed in the FAQ if you think running as admin will help.

As far as Send and hotkeys are concerned, running as admin almost never provides any benefit over running with UI access. Either one will generally only help if the active window is running as admin.

KeyHistory is a command you can call. The documentation also points out that you can access the same functionality via the View menu of the script's main window, which normally opens when you double click the tray icon.

No one was suggesting to use EnableUIAccess on any executable as far as I can tell. I see no reason to use it on "a program other than AutoHotkey", and if someone suggested to use it on AutoHotkey I would direct them to Run with UI Access, which supersedes it (and is also mentioned in the aforementioned FAQ).