Distinguish between 3 connected keyboards

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Archimede
Posts: 464
Joined: 25 Nov 2021, 09:49
Location: Switzerland / Italy

Distinguish between 3 connected keyboards

Post by Archimede » 27 Jun 2022, 10:22

Hallo.
Like the title.
I have 3 keyboards connected to the PC.
When I press a key on a keyboard I want to detect what keyboard pressed that key.
Is it possible? How?
Thank you very much

gregster
Posts: 8920
Joined: 30 Sep 2013, 06:48

Re: Distinguish between 3 connected keyboards

Post by gregster » 27 Jun 2022, 10:24

:arrow: AutoHotInterception by evilC
It's not a trivial task.

Archimede
Posts: 464
Joined: 25 Nov 2021, 09:49
Location: Switzerland / Italy

Re: Distinguish between 3 connected keyboards

Post by Archimede » 27 Jun 2022, 10:28

I know.
Is it possible by AutoHotKey?
I hope yes...

gregster
Posts: 8920
Joined: 30 Sep 2013, 06:48

Re: Distinguish between 3 connected keyboards

Post by gregster » 27 Jun 2022, 10:37

Afaik, you need to access a lower system level than normal AHK remapping does. There is AHKHID, but it also has certain restrictions, if I remember correctly.

There is also that guy who used HID with Lua to run AHK scripts, or smth like that... https://www.youtube.com/watch?v=Arn8ExQ2Gjg

Archimede
Posts: 464
Joined: 25 Nov 2021, 09:49
Location: Switzerland / Italy

Re: Distinguish between 3 connected keyboards

Post by Archimede » 27 Jun 2022, 10:56

Interesting.
It tell Lua macros with AutoHotkey can do it, but it no tell how.
Can you tell me some thing about? Or other systems?
Thank you very much

gregster
Posts: 8920
Joined: 30 Sep 2013, 06:48

Re: Distinguish between 3 connected keyboards

Post by gregster » 27 Jun 2022, 19:13

There are a couple of links under the YT video (expand the description). I have only tried AHI some time ago - seemed to work fine.
Perhaps others have more ideas.

Jasonosaj
Posts: 46
Joined: 02 Feb 2022, 15:02
Location: California

Re: Distinguish between 3 connected keyboards

Post by Jasonosaj » 28 Jun 2022, 12:24

I don't know if there's a limitation on 3 versus 2 keyboards, but I just set up the combination of EvilC's Autohotinterception, interceptiontaphold, and tapholdmanager, and the Interception driver to separate inputs from my TKL and my separate numpad. It works as advertised and wasn't too difficult - my competence is only slightly higher than my black Lab (who's admittedly brighter than the brown...)

Here's the relevant portions of the script:

Code: Select all

#Persistent
#SingleInstance force  ; Ensures that only the last executed instance of script is running
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir, %A_ScriptDir%  ; Ensures a consistent starting directory.
Menu, tray, icon, %A_ScriptDir%\Media\jjk.ico

#Include <Vis2>
#Include <AutoHotInterception>
#include <InterceptionTapHold>
#include <TapHoldManager>

#Include %A_ScriptDir%\lib\
#include biga\export.ahk
#Include array\export.ahk
#Include stringsimilarity\export.ahk
#Include json\export.ahk
and

Code: Select all


AHI := new AutoHotInterception()

KeyboardID1 := AHI.GetKeyboardId(0x0C45, 0x7692)	; 	Keyboard identifier for IHT
KeyboardID2 := AHI.GetKeyboardId(0x04B4, 0x0901)	;	Numpad identifier to IHT

ITH1 := new InterceptionTapHold(AHI, KeyboardID1)	; 	Keyboard assignments via IHT

ITH1.Add("Capslock", Func("CapsMenu"))			; 	Caps to disabled v. Capsmenu
ITH1.Add("F3",  Func("SearchMenu"))				;	F3 to search menu v. quick search 

ITH2 := new InterceptionTapHold(AHI, KeyboardID2)	;	Numpad assignments via IHT 

ITH2.Add("Esc", Func("NPEscape"))				;	Escape to !F1
ITH2.Add("Tab", Func("NPTab"))					;	Tab to !F2
ITH2.Add("Backspace", Func("NPBackspace"))		; 	Backspace to #C
ITH2.Add("NumpadEnter",  Func("NPEnter"))		; 	Program-specific Enter remaps

and

Code: Select all

SearchMenuHotkey(isHold, taps, state){
	if (taps==1) {
		Menu, SearchMenu, Show
		Return
		} 
	else if (taps==2) {
		DDGSearch()
		return
		}
	else if (taps==3) {
		Send, {F3}
		Return
		}
	}

CapslockSemiDisable(isHold, taps, state) {
	If (taps==2) {
		counter = 0
		Gosub, CAPSMENU
		if (stringGlobal){
			clipboard := stringGlobal
			Return
			} 
		else {
			Clipboard := OldClipboard
			Return
			}
		}
	}

NumPadEnterFunc(){
	If WinActive("Calculator ahk_class ApplicationFrameWindow, Calculator") {
		SendInput, {Enter}
		SendInput, ^c
		return
		}
	Else If Winactive("ahk_exe excel.exe") {
		Send, {NumpadEnter}  
		sleep, 0.2
		Return
		}
	Else {
		SendInput, {=}
		sleep, 0.2
		Return
		}
}

NumPadEscapeFunc(){
	If WinActive("ahk_exe brave.exe") {
		SendInput, {Alt}{f1}
		Return
		}
	Else {
		SendInput, {F1}
		Return
		}
	}

NumpadTabFunc(){
	If WinActive("ahk_exe brave.exe") {
		SendInput, {Alt}{f2}
		Return
		}
	Else {
		SendInput, {F2}
		Return
		}
	}	

NumPadBackspaceFunc(){
	if WinExist("Calculator ahk_class ApplicationFrameWindow", "Calculator") {
		WinActivate
		return
			}
	else {
		Run calc.exe
		return
		}
}

Post Reply

Return to “Ask for Help (v1)”