AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!

Post your working scripts, libraries and tools
User avatar
evilC
Posts: 4739
Joined: 27 Feb 2014, 12:30

Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!

01 May 2019, 04:25

Because you are using an AHK hotkey to detect the keystroke, but Interception to send the output. AHK will see keys sent by interception.

Use Interception to detect the keystroke (Use SUBSCRIPTION MODE) and it won't self trigger, because Interception does not see the input it sends
k1ngjosh
Posts: 2
Joined: 02 Jul 2019, 12:22

Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!

02 Jul 2019, 16:21

Is there a way I can make the script execute only once regardless of how long I hold down the "a" key? When I press and release "a" I get the output of josh once, but when I hold down "a" josh is spammed very fast. I would like it to run only once per press regarless of how long I hold down the key. Thanks
Code Text:
User avatar
evilC
Posts: 4739
Joined: 27 Feb 2014, 12:30

Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!

03 Jul 2019, 04:10

Code: Select all

KeyEvent(state){
	global AHI, keyboardId
	static cs
	if (!state){
		cs := 0
		return
	}
	if (cs)
		return
	cs := state
	AHI.SendKeyEvent(keyboardId, GetKeySC("j"), 1)
	AHI.SendKeyEvent(keyboardId, GetKeySC("j"), 0)
	AHI.SendKeyEvent(keyboardId, GetKeySC("o"), 1)
	AHI.SendKeyEvent(keyboardId, GetKeySC("o"), 0)
	AHI.SendKeyEvent(keyboardId, GetKeySC("s"), 1)
	AHI.SendKeyEvent(keyboardId, GetKeySC("s"), 0)
	AHI.SendKeyEvent(keyboardId, GetKeySC("h"), 1)
	AHI.SendKeyEvent(keyboardId, GetKeySC("h"), 0)
}
k1ngjosh
Posts: 2
Joined: 02 Jul 2019, 12:22

Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!

05 Jul 2019, 11:47

Thanks for the solution, works great. Is there a way I could implement an on/off toggle to have a key to activate/deactivate the script when pressed?
Edit: Saw your response, thanks it works great
Last edited by k1ngjosh on 19 Jul 2019, 20:10, edited 2 times in total.
User avatar
evilC
Posts: 4739
Joined: 27 Feb 2014, 12:30

Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!

09 Jul 2019, 09:05

v0.4.4 has been released!
Please note that this also contains changes from the v0.4.3 release, which was not announced on this thread as it was experimental.
@k1ngjosh - this release includes a new SetStatus function that you can call to turn on / off subscriptions.

Example usage (The F12 hotkey turns on / off subscriptions - note that it starts ON, so the first time it is called, you should pass false to turn it off)

Code: Select all

#include Lib\AutoHotInterception.ahk

AHI := new AutoHotInterception()

keyboardId := AHI.GetKeyboardId(0x04F2, 0x0112)
AHI.SubscribeKey(keyboardId, GetKeySC("1"), true, Func("KeyEvent"))
toggle := true
return

KeyEvent(state){
	ToolTip % "State: " state
}

F12::
	toggle := !toggle
	AHI.SetState(toggle)
	return
BenevolentDeity
Posts: 2
Joined: 01 Aug 2019, 17:49

Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!

01 Aug 2019, 23:39

Is this the application that Taran (of second keyboard fame) indicated has a price tag of about $2200 if support for more than 10 devices is required?
User avatar
evilC
Posts: 4739
Joined: 27 Feb 2014, 12:30

Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!

02 Aug 2019, 04:28

That's the Interception driver, which this library uses
We tried to pay the money to get that upgraded version, but he would not sell for a one off fee - instead he set up a patreon account and asked for a monthly income and would release it after 6 months or so.
You can see the conversation here: https://github.com/oblitum/Interception/issues/25
Astrocam
Posts: 1
Joined: 20 Aug 2019, 10:32

Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!

20 Aug 2019, 10:37

First of all, thank you for building this. I can't wait to get it working.

Downloaded and extracted files, copied Library files to lib, unblocked .dlls, installed driver (I think), restarted pc, removed and reinserted device, and . . .Motitor.ahk is still just a blank GUI.
What am I missing here? Did I skip a step?

Thanks for your help.
User avatar
evilC
Posts: 4739
Joined: 27 Feb 2014, 12:30

Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!

20 Aug 2019, 10:50

installed driver (I think)
It should be very obvious if you did it right, you will get a response back from the command-line saying that install was successful.
Did you maybe just double-click the EXE instead of running it from a command-line?
FordeD
Posts: 5
Joined: 31 May 2018, 15:12
GitHub: McFree

Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!

23 Aug 2019, 07:36

@evilC
i can't get devices from GetDeviceList()
Array length = 0
I test it in monitor script, and monitor script can't give me my devices list. Why?
I install Interception from command line (in administrator)
tmplinshi
Posts: 1520
Joined: 01 Oct 2013, 14:57

Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!

23 Aug 2019, 11:44

Hi, thanks for lib. I have problems running some of the examples:
---------------------------
Context Example.ahk
---------------------------
Error in #include file "G:\Download\AutoHotInterception\Lib\AutoHotInterception.ahk":
0x80020006 - Unknown name.

Specifically: GetDeviceIdFromHandle

Line#
108: {
109: MsgBox,"Could not get " devType[isMouse] " with VID " VID ", PID " PID ", Instance " instance
110: ExitApp
111: }
112: Return,dev
113: }
115: {
---> 117: dev := this.Instance.GetDeviceIdFromHandle(IsMouse, handle, instance)
118: if (dev == 0)
118: {
119: MsgBox,"Could not get " devType[isMouse] " with Handle " handle ", Instance " instance
120: ExitApp
121: }
122: Return,dev
123: }

Continue running the script?
All I did is I replaced
id1 := AHI.GetKeyboardId(0x04F2, 0x0112, 1)
to
id1 := AHI.GetKeyboardIdFromHandle("ACPI\VEN_PNP&DEV_0303")

Although I got it working by modifying the GetKeyboardIdFromHandle method in AutoHotInterception.ahk:

Code: Select all

	GetKeyboardIdFromHandle(handle, instance := 1) {
		; return this.GetDeviceIdFromHandle(false, handle, instance)
		return this.Instance.GetKeyboardIdFromHandle(handle, instance)
	}
User avatar
evilC
Posts: 4739
Joined: 27 Feb 2014, 12:30

Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!

23 Aug 2019, 11:55

Ohh, I think I maybe see the issue - it's passing true/false, but the GetDeviceIdFromHandle method uses a lookup table with 1/0 for keys.
I am not sure what I was smoking when I wrote that

Does this also fix it?
[code]
GetKeyboardIdFromHandle(handle, instance := 1) {
return this.GetDeviceIdFromHandle(0, handle, instance)
}
[/code]

Edit, actually, no, doesn't look like it would, that lookup table is only for the error message
I think it is maybe related to how AHK C# interop works with booleans?

Ohh, I see the issue, I moved that method to a helper class in the C#
User avatar
evilC
Posts: 4739
Joined: 27 Feb 2014, 12:30

Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!

23 Aug 2019, 16:28

v0.4.8 of AHI has been released!
https://github.com/evilC/AutoHotInterception/releases/tag/v0.4.8
Fixed the bug @tmplinshi just reported
Updated the Monitor app - there are now Copy buttons to copy the VID/PID of your device to the clipboard

[Edit] I forgot to prefix the VID/PID with 0x, so I deleted release 0.4.7 and re-released as 0.4.8
tmplinshi
Posts: 1520
Joined: 01 Oct 2013, 14:57

Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!

24 Aug 2019, 01:17

Thanks for the update! It works now.

Just a small bug of the Copy buttons, it copies wrong result, the & character becomes &&.
For example I got ACPI\VEN_PNP&&DEV_0303 instead of ACPI\VEN_PNP&DEV_0303.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: dead_line, DuyMinh and 13 guests