Multiple Hotkey actions for the same hotkey

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
cba
Posts: 2
Joined: 30 Mar 2023, 13:07

Multiple Hotkey actions for the same hotkey

Post by cba » 30 Mar 2023, 13:32

Hello,

In my scripts. I'm dynamically registering the hotkeys with the Hotkey function.

The documentation is clear about the fact that there can be only one Action for a KeyName that is managed by Hotkey function.

However, I need to use multiple actions (for one KeyName).

Is there a recommended approach to this or my case described below?

My need for this is that I want separate and independent actions for the same hotkey.
For example:
The first library that I'm using is using CapsLock to implement window switching with one key. Specifically: pressing CapsLock holds down LAlt and presses Tab; subsequent presses of CapsLock press Tab; this ends (and releases LAlt) after timeout or by pressing another key. So this library is registering a hotkey for all keys on the keyboard to detect the "another key" press. At the end, the hotkeys are turned off (by Hotkey function.)
My second library is hadling key presses as well to basically rewrite key to%omething else (think of swapping two keys on the keyboard).
The problem is that when the first library finishes, it turns off all the hotkeys, therefore the hotkeys that the second library relies on are also disabled.

Thank you for the help.

User avatar
mikeyww
Posts: 26890
Joined: 09 Sep 2014, 18:38

Re: Multiple Hotkey actions for the same hotkey

Post by mikeyww » 30 Mar 2023, 17:55

Welcome to this AutoHotkey forum!

Since you control your Hotkey function calls, you can exclude whichever keys you want. An alternative is using InputHook.

cba
Posts: 2
Joined: 30 Mar 2023, 13:07

Re: Multiple Hotkey actions for the same hotkey

Post by cba » 16 May 2023, 17:36

@mikeyww Thank you. I wasn't aware of InputHook. I was able to implement my use case with it.

Post Reply

Return to “Ask for Help (v2)”