Can AHK distinguish between TWO different keyboards? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
watchmaker

Can AHK distinguish between TWO different keyboards?

11 May 2015, 15:32

Is it possible to recognize keystrokes from two different USB keyboards, e. g. a regular keyboard and an USB calculator numpad? I need to remap several buttons on the keypad but NOT to remap the same butons on the main keyboard.
geek
Posts: 1055
Joined: 02 Oct 2013, 22:13
Location: GeekDude
Contact:

Re: Can AHK distinguish between TWO different keyboards?

11 May 2015, 15:37

Kind of. With the AHKHID library you can get all sorts of fun information about what kind of device is delivering the key strokes. The only problem is that you can't make blocking remaps this way. You might be able to block every key, then Send virtual keystrokes for the same keys if it's the main keyboard, or whatever you want if it's the secondary keyboard. The AHKHID library can be really complicated to use though, so your mileage may vary.
watchmaker

Re: Can AHK distinguish between TWO different keyboards?

11 May 2015, 15:53

I don't want to block the keys, I want to remap some keys on the keypad (and only in one application) without remapping them on the regular keyboard.
geek
Posts: 1055
Joined: 02 Oct 2013, 22:13
Location: GeekDude
Contact:

Re: Can AHK distinguish between TWO different keyboards?

11 May 2015, 15:58

Part of remapping is blocking the original keystroke. AutoHotkey doesn't have the ability to block keys selectively based on which keyboard it came from. What AutoHotkey can do is block indiscriminately and then reproduce the original keystroke if it shouldn't be blocked. This is what I have suggested
User avatar
Nextron
Posts: 1391
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win10 AHK: Unicode x32

Re: Can AHK distinguish between TWO different keyboards?

11 May 2015, 15:58

watchmaker wrote:I don't want to block the keys, I want to remap some keys on the keypad (and only in one application) without remapping them on the regular keyboard.
But that'll probably involve blocking the native function. For example, if you'd want the NumPadEnter to launch TaskManager, you probably don't want the Enter event to reach the active window, for example a browser that submits a form.

Look into HIDmacros (eol) or it's more scripted successor LuaMacros. It allows distinction between input devices AND block the native function.
geoffff
Posts: 4
Joined: 09 Dec 2015, 14:06

Re: Can AHK distinguish between TWO different keyboards?

09 Dec 2015, 15:35

I tried HidMacros/LuaMacros to modify/block keys on a particular USB keyboard before they reached AutoHotkey, but I found that it didn’t do a good job of keeping track of my USB keyboards when I unplugged them and plugged them back in again.

Instead I ended up using Interception and this command-line interface for it posted by user kamaz on Orbiter Forum. This tool does modify or block keys before they reach AutoHotkey. It uses only a subset of the keyboard ID (ignores the GUID part) so the same keyboard is still recognized when it's unplugged and plugged back in again, even if the GUID changes.

Install steps:
• Run the interception installer in the Interception.zip file from GitHub and reboot. Do not run the old installer linked by kamaz in the Orbiter Forum post.
• Download kamaz’s intercept.exe tool posted on Orbiter Forum (intercept.zip). You can use this intercept.exe command-line tool to configure your keyboard remappings, or directly edit the keyremap.ini file it uses. Try making a few remappings and save them to understand the keyremap.ini file format.
• Optional: Use my start-intercept.vbs (start-intercept.zip) tool to automatically configure intercept.exe to run when you start Windows, without requiring a command prompt window to be left lying around. I placed a shortcut to start-intercept.vbs in my Windows Startup Programs folder.

You can download my copies of everything from here if you like: interception.zip

-- Geoff
fizzybrain
Posts: 7
Joined: 19 Dec 2015, 18:22

Re: Can AHK distinguish between TWO different keyboards?

19 Dec 2015, 19:54

(This is my first post on these forums, having found Autohotkey very useful for dealing with a 80%-functional keyboard on a salvaged keyboard - I mapped all fn-keys to letters! This should maybe be a new thread, but it seems to follow on very well from the previous posts.)

I too would like to remap keypresses on multiple external keyboards - USB numeric keypads in this case. The idea is to end up with an ultra-cheap split keyboard (with similar concepts to Ergo Dox, "tie-fighter"-style, TEK, etc). Very cheap 19- and 23-key keypads can be bought on ebay for peanuts (yes, I know the keys will probably be spongy and horrid, but that doesn't bother me), so I'm thinking 4 identical keypads and some AHK tweaking could give full functionality. I'm at the earliest stage, working out what software to use - I'm not committed to anything in particular (except it should be FOSS, ideally), though AHK obviously seems very useful for this sort of project.

I have read up a bit about using multiple keyboards with HIDmacros, but IIUC it can't cope with simultaneous keypresses - not in the way I will want to anyway (I will want one ENTER Key to work as SHIFT, "+" might be CTRL, etc). Does anyone know if Luamacros would solve this?

The Interception code seems promising, and I think it can trap everything (i.e. it won't be confused by Numlock, etc) but comments suggest that it might have difficulty with multiple *identical* keyboards.
Any thoughts on the best way to proceed? I'm thinking a combination of Interception and AHK - Geoffff, do you think this could work? (and thanks for sharing your work already)

Cheers, and compliments of the season to all!
fizzybrain
Posts: 7
Joined: 19 Dec 2015, 18:22

Re: Can AHK distinguish between TWO different keyboards?

27 Dec 2015, 15:01

Thanks IMEime.
Well, I bought a cheaper-than-cheap usb numeric keypad and used Interception - partial success.
I found the "official" page rather daunting which had been putting me off, but I found related pages on the orbiter forum very inspiring - it truly was very very easy! (actually, no it wasn't as I kept getting stray input, but I'm guessing that is due to the crappiness of the keypad - I got round that by direct editing of the .ini file)
Sadly, I found that my keypad had a couple of problems:
- the Numlock key didn't actually send a code as such, but modified the output of the keypad itself (such that pressing a key with Numlock "on" actually sent code: [Numlock v][Numlock ^][KEY v][KEY ^][Numlock v][Numlock ^]) I wanted to remap the numlock key itself to use it as a standard key - as I can do with a different keypad - so that's no good for me.
- the "000" button sends three numeric "0"s, rather than three *main keyboard* "0"s (as some keypads do, apparently), which means I can't properly remap that either.
This makes it useless for my original purpose (I wanted to make a small split QWERTY keyboard using two of them on their sides, with AHK handling shift, alt, etc.), but it's good to see how easy it is to remap the rest of the keys using Interception - it'll be handy for other projects.
(I've ordered another cheap keypad to see if that handles numlock and 000 differently...)
Cheers all
Guest

Re: Can AHK distinguish between TWO different keyboards?

10 Jul 2017, 10:05

geoffff wrote:I tried HidMacros/LuaMacros to modify/block keys on a particular USB keyboard before they reached AutoHotkey, but I found that it didn’t do a good job of keeping track of my USB keyboards when I unplugged them and plugged them back in again.

Instead I ended up using Interception and this command-line interface for it posted by user kamaz on Orbiter Forum. This tool does modify or block keys before they reach AutoHotkey. It uses only a subset of the keyboard ID (ignores the GUID part) so the same keyboard is still recognized when it's unplugged and plugged back in again, even if the GUID changes.

Install steps:
• Run the interception installer in the Interception.zip file from GitHub and reboot. Do not run the old installer linked by kamaz in the Orbiter Forum post.
• Download kamaz’s intercept.exe tool posted on Orbiter Forum (intercept.zip). You can use this intercept.exe command-line tool to configure your keyboard remappings, or directly edit the keyremap.ini file it uses. Try making a few remappings and save them to understand the keyremap.ini file format.
• Optional: Use my start-intercept.vbs (start-intercept.zip) tool to automatically configure intercept.exe to run when you start Windows, without requiring a command prompt window to be left lying around. I placed a shortcut to start-intercept.vbs in my Windows Startup Programs folder.

You can download my copies of everything from here if you like: interception.zip

-- Geoff
I realize it's been 2 years since this, but let's give it a try:

I would benefit HUGELY from being able to use a standard keyboard as all new customizable macro keyboard, for my music notation/arranging work.
I downloaded the intercept folder and lua but sadly have zero experience with coding, it always scared me and my time is seriously limited due to work.

Would anyone be able to assist me just to get started please? I have an extra keyboard, all the assets downloaded, but gut stuck in the process described above.

There's an entire community of musicians that would benefit from this (I'm sure many would be willing to donate for help).

Thank you,
Vlad
MikuGeniu
Posts: 2
Joined: 12 Oct 2019, 21:07

Re: Can AHK distinguish between TWO different keyboards?

02 Nov 2019, 20:51

geoffff wrote:
09 Dec 2015, 15:35
I tried HidMacros/LuaMacros to modify/block keys on a particular USB keyboard before they reached AutoHotkey, but I found that it didn’t do a good job of keeping track of my USB keyboards when I unplugged them and plugged them back in again.

Instead I ended up using Interception Broken Link for safety and this command-line Broken Link for safety interface for it posted by user kamaz on Orbiter Forum. This tool does modify or block keys before they reach AutoHotkey. It uses only a subset of the keyboard ID (ignores the GUID part) so the same keyboard is still recognized when it's unplugged and plugged back in again, even if the GUID changes.

Install steps:
• Run the interception installer in the Interception.zip file from GitHub and reboot. Do not run the old installer linked by kamaz in the Orbiter Forum post.
• Download kamaz’s intercept.exe tool posted on Orbiter Forum (intercept.zip). Broken Link for safety You can use this intercept.exe command-line tool to configure your keyboard remappings, or directly edit the keyremap.ini file it uses. Try making a few remappings and save them to understand the keyremap.ini file format.
• Optional: Use my start-intercept.vbs (start-intercept.zip) Broken Link for safety tool to automatically configure intercept.exe to run when you start Windows, without requiring a command prompt window to be left lying around. I placed a shortcut to start-intercept.vbs in my Windows Startup Programs folder.

You can download my copies of everything from here if you like: interception.zip Broken Link for safety

-- Geoff
Hello geofff,is there a better soulution in 2019?Interception only supports 10 device,it's annoying.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: DecimalTurn, macromint, peter_ahk and 354 guests