Page 1 of 1

InputHook small improvement - different keyboards

Posted: 28 Sep 2019, 18:40
by 0xDEADC0DE
The new InputHook looks very interessting.
For me it would solve a lot of problems if I could distinguish between different keyboards.
So the hook should have the option to only react on keys pressed on a specific keyboard or
also good would be if the hook would return me some information on which keyboard the
hook was pressed.

In my case, I need it to have different hotkeys on my notebook and on my external keyboard.
E.g. on my external keyboard, I use right Ctrl very often, on my notebook not so I have remapped it
to the context menu key.
Currently I need to disable this hotkey when I plugin my notebook into my docking station.

Re: InputHook small improvement - different keyboards

Posted: 28 Sep 2019, 23:42
by lexikos
Low level keyboard hooks can detect and intercept/block input, but cannot differentiate between keyboards.
Raw Input can differentiate between keyboards, but cannot intercept/block input.
Keyboard filter drivers can do all of this and more, but cannot reside within a user mode program.

AutoHotkey uses only a low level keyboard hook. InputHook is built around its capabilities.

In short, what you ask is possible in general, but is unlikely to ever become part of AutoHotkey itself.

Re: InputHook small improvement - different keyboards

Posted: 29 Sep 2019, 04:43
by 0xDEADC0DE
What a pitty. With a function I could query to get the keyboard used for the keypress, there would be a lot of possibilities.
Thanks for your answer.

Re: InputHook small improvement - different keyboards

Posted: 29 Sep 2019, 05:38
by ahk7
@0xDEADC0DE perhaps:

1. AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK.
https://www.autohotkey.com/boards/viewtopic.php?f=6&t=45307

2. AHKHID
https://autohotkey.com/board/topic/38015-ahkhid-an-ahk-implementation-of-the-hid-functions/

3. HIDMacros (using external program)
https://autohotkey.com/board/topic/55921-multiple-keyboards-workaround/
HIDMacros is no longer developed, but there is a successor by the same dev. luamacros
https://github.com/me2d13/luamacros
which seems to work with AHK as well https://github.com/resir014/ahk-luamacros-test

Re: InputHook small improvement - different keyboards

Posted: 29 Sep 2019, 15:27
by 0xDEADC0DE
Thanks for the links.
It's a bit much to do for what I want to do.

Re: InputHook small improvement - different keyboards

Posted: 05 Nov 2019, 12:28
by evilC
AHKHID and HIDMacros can differentiate keyboards, but cannot block
I forget if I added the functionality to AutoHotInterception to notify on all keys, but could add it if not - under the hood you subscribe to a whole device anyway, so it would be fairly simple to just add a flag to fire the callback for all keys

Re: InputHook small improvement - different keyboards

Posted: 15 Dec 2019, 18:13
by evilC
AHI 0.5.0 now has a function to subscribe to all keys on a specific keyboard