Reinstalling Keyboard or mouse hook?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Flowgun
Posts: 75
Joined: 25 Aug 2022, 09:42

Reinstalling Keyboard or mouse hook?

16 Jul 2023, 00:14

Hello,
I just updated to 1.1.37.01.
In the previous versions, the mouse hotkeys wouldn't work for me after I lock the pc or put it to sleep, so I modified my scripts to restart automatically after logging in (suspending and resuming the hotkeys doesn't fix the issue).
I believe the issue happens also if the script is run too early on windows startup, so I also set them up to restart if they were run too early from windows start.
I would love to find another way since sometimes I like to keep the values of certain variables in memory and so on.

I read this in the 1.1.37.01 changelog:
Fixed an issue where any attempt to reinstall the keyboard or mouse hook would fail if the OS had automatically uninstalled the hook. It is still necessary to meet certain conditions before any such attempt can be made.
Does this help in my situation? also what are the certain conditions that need to be met so that one can meet them?
User avatar
mikeyww
Posts: 27146
Joined: 09 Sep 2014, 18:38

Re: Reinstalling Keyboard or mouse hook?

16 Jul 2023, 06:17

I wonder if the problem is actually that a different program is attempting to use the same hotkeys. In that case, you should probably try to resolve that conflict directly.
2_05
Posts: 31
Joined: 09 May 2018, 10:28

Re: Reinstalling Keyboard or mouse hook?

18 Jul 2023, 00:37

Are you using AHK 32-bit? Then have a look at this topic. That topic was also the reason for that particular change.

It's not possible to detect if the system is ready to set the hotkey, without knowing the actual cause of why the hotkeys are failing. This may well be caused by another program, that does something to the hook register. In that case a solution may be to check the state of this particular program before setting the hotkey, if it's even possible to derive such state.

Another approach would be to regularly test if the hotkeys are still valid, but as mentioned by lexikos in the above mentioned topic, there would be caveats.

In your case I would test to see if instead of restarting the script Suspend On now works for your situation. If that works it's probably the easiest solution.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Dobbythenerd1, Giresharu and 107 guests