Tweaked some stuff to try and debug what is going on with PS/2 devices.
I altered the GetDeviceList() function to return all devices, even those without a VID and PID
This should make *something* appear in the monitor script for PS/2 devices
Furthermore I added a "Handle" parameter, so we can see the raw device handles
Attached a zip with the changed files
AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!
Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!
- Attachments
-
- PS2.zip
- (11.26 KiB) Downloaded 302 times
Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!
Thank You. It works now.
How can I remap up key?
How can I remap up key?
Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!
@malcev I see no issue with subscribing to up and down, but I do see an issue with SendKeyEvent and ScanCodes > 256
Test script (Should remap Up to Down and vice versa):
The way Interception represents right variants of keys (eg Right ALT etc) means that if SC is > 256, I do some custom logic.
This seems to not work for arrow keys
Attached is a replacement DLL which should let you send arrow keys, but I am not sure how to deal with this going forwards.
I have raised an Issue on GitHub regarding this
Test script (Should remap Up to Down and vice versa):
Code: Select all
#SingleInstance force
#Persistent
#include Lib\AutoHotInterception.ahk
AHI := new AutoHotInterception()
;~ keyboardId := AHI.GetKeyboardId(0x04F2, 0x0112)
keyboardId := AHI.GetKeyboardId(0x413C, 0x2107)
AHI.SubscribeKey(keyboardId, GetKeySC("Up"), true, Func("KeyEvent").Bind(GetKeySC("Down")))
AHI.SubscribeKey(keyboardId, GetKeySC("Down"), true, Func("KeyEvent").Bind(GetKeySC("Up")))
return
KeyEvent(code, state){
global AHI, keyboardId
AHI.SendKeyEvent(keyboardId, code, state)
ToolTip % "State: " state
}
^Esc::
ExitApp
This seems to not work for arrow keys
Attached is a replacement DLL which should let you send arrow keys, but I am not sure how to deal with this going forwards.
I have raised an Issue on GitHub regarding this
- Attachments
-
- AutoHotInterception.zip
- (8.51 KiB) Downloaded 194 times
Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!
Oh, and if it now works with the PS/2 keyboard, could you possibly paste a screenshot of the monitor?
Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!
You can't at the moment, which is what I intend to rectify.malcev wrote: How can I use keyboardId := AHI.GetKeyboardId(0x413C, 0x2107) with handle only?
For the time being, you can just pass the interception ID instead.
eg
Code: Select all
keyboardId := 1
AHI.SubscribeKey(keyboardId, GetKeySC("Up"), true, Func("KeyEvent").Bind(GetKeySC("Down")))
Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!
Attached is a test of a new version that should let you get device ID from handle
Added methods:
GetKeyboardIdFromHandle(handle, instance := 1)
GetMouseIDFromHandle(handle, instance := 1)
Please test it all works for you, and I will push out a new release
I am guessing AHI.GetKeyboardIdFromHandle("ACPI\PNP0303") should work for you
Added methods:
GetKeyboardIdFromHandle(handle, instance := 1)
GetMouseIDFromHandle(handle, instance := 1)
Please test it all works for you, and I will push out a new release
I am guessing AHI.GetKeyboardIdFromHandle("ACPI\PNP0303") should work for you
- Attachments
-
- AutoHotInterception.zip
- (375.32 KiB) Downloaded 168 times
Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!
I think here is error:
It should be:
And if I use this code
then "up" remaps to "P" and down remaps to "H".
Code: Select all
GetKeyboardIdFromHandle(handle, instance := 1){
return this.GetDeviceId(false, handle, instance)
}
GetMouseIDFromHandle(handle, instance := 1){
return this.GetDeviceId(true, handle, instance)
}
Code: Select all
GetKeyboardIdFromHandle(handle, instance := 1){
return this.GetDeviceIdFromHandle(false, handle, instance)
}
GetMouseIDFromHandle(handle, instance := 1){
return this.GetDeviceIdFromHandle(true, handle, instance)
}
Code: Select all
#SingleInstance force
#Persistent
#include Lib\AutoHotInterception.ahk
AHI := new AutoHotInterception()
keyboardId := 1
AHI.SubscribeKey(keyboardId, GetKeySC("Up"), true, Func("KeyEvent").Bind(GetKeySC("Down")))
AHI.SubscribeKey(keyboardId, GetKeySC("Down"), true, Func("KeyEvent").Bind(GetKeySC("Up")))
return
KeyEvent(code, state){
global AHI, keyboardId
AHI.SendKeyEvent(keyboardId, code, state)
ToolTip % "State: " state
}
Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!
Good catch on the first one
Regarding the up/down not mapping again - that did not make it into this commit. The version I posted for you before was a bodge just to make sure I identified what the issue was.
I will be looking into a proper fix for that one ASAP
Attached is a DLL with these new changes, and the Up/Down bodge
Regarding the up/down not mapping again - that did not make it into this commit. The version I posted for you before was a bodge just to make sure I identified what the issue was.
I will be looking into a proper fix for that one ASAP
Attached is a DLL with these new changes, and the Up/Down bodge
- Attachments
-
- AutoHotInterception.zip
- (8.61 KiB) Downloaded 161 times
Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!
Now it works.
Thank You!
Thank You!
Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!
AHA! I took another look at the code that deals with ScanCode > 255, and it was broken for all of them, not just up.
Old code:
DUH!! Interception uses 0 for press, 1 for release, or +2 to each of those if extended.
The above logic clearly only works properly when ScanCodes are < 256
It should do 1-state, and THEN add 2 if needed
New code:
Old code:
Code: Select all
public void SendKeyEvent(int id, ushort code, int state)
{
var stroke = new ManagedWrapper.Stroke();
if (code > 255)
{
code -= 256;
state += 2;
}
stroke.key.code = code;
stroke.key.state = (ushort)(1 - state);
ManagedWrapper.Send(_deviceContext, id, ref stroke, 1);
}
The above logic clearly only works properly when ScanCodes are < 256
It should do 1-state, and THEN add 2 if needed
New code:
Code: Select all
public void SendKeyEvent(int id, ushort code, int state)
{
IsValidDeviceId(false, id);
var st = 1 - state;
var stroke = new ManagedWrapper.Stroke();
if (code > 255)
{
code -= 256;
st += 2;
}
stroke.key.code = code;
stroke.key.state = (ushort)st;
ManagedWrapper.Send(_deviceContext, id, ref stroke, 1);
}
Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!
AHI 0.3.5 has been released!
Adds support for Horizontal Wheel on Mice - thanks @crumbl3d !
Instance is now correctly passed through in GetDeviceID and variants
GetDeviceIdFromHandle, GetKeyboardIdFromHandle, GetMouseIDFromHandleadded to enable support for PS/2 and Laptop devices
Fix for SendKeyEvent when using ScanCodes > 255
Adds support for Horizontal Wheel on Mice - thanks @crumbl3d !
Instance is now correctly passed through in GetDeviceID and variants
GetDeviceIdFromHandle, GetKeyboardIdFromHandle, GetMouseIDFromHandleadded to enable support for PS/2 and Laptop devices
Fix for SendKeyEvent when using ScanCodes > 255
-
- Posts: 137
- Joined: 01 Jul 2017, 03:04
Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!
Code: Select all
MonitorWrapper := new AutoHotInterception("Monitor")
Monitor := MonitorWrapper.Instance
Monitor.Subscribe(Func("KeyboardEvent"), Func("MouseEvent"))
-
- Posts: 137
- Joined: 01 Jul 2017, 03:04
Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!
evilC wrote:Adds support for Horizontal Wheel on Mice
Code: Select all
AHI.Instance.SendMouseButtonEvent(12, 6, 1)
-
- Posts: 137
- Joined: 01 Jul 2017, 03:04
Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!
I now understand it is necessary to use to unsubscribe
But is it necessary to destroy the Monitor and MonitorWrapper objects?
And where to read about SetDeviceFilterState and the rest?
Code: Select all
Monitor.SetDeviceFilterState(dev.id, 0)
And where to read about SetDeviceFilterState and the rest?
-
- Posts: 137
- Joined: 01 Jul 2017, 03:04
Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!
It is impossible to send Numlock - sc145.Fix for SendKeyEvent when using ScanCodes > 255
Although it sends sc145 but at the same time vkFF is not vk90.
But if to send sc45 then it is defined as Numlock, although sc45 is Pause.
Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!
-
- Posts: 137
- Joined: 01 Jul 2017, 03:04
Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!
SubscribeKey too it is impossible to unloaded ?evilC wrote:The Monitor was never designed to be loaded / unloaded dynamically
-
- Posts: 137
- Joined: 01 Jul 2017, 03:04
Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!
It seems to me that in such a topic it is necessary to unload all methods, including the instance itself.
Return to “Scripts and Functions (v1)”
Who is online
Users browsing this forum: No registered users and 207 guests