v0.4.9 released with the fix for the && issue
Thanks once again tmplinishi!
AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!
-
- Posts: 3
- Joined: 07 Oct 2019, 02:15
Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!
Hi,
What is the proper way to use AHI with several Winactive conditions?
I use several #If cm1.IsActive && WinActive("ahk_exe xxxx.exe"), for different apps but sometimes the hotkey is not sent.
Autohokey catches the key each time, but cm1.IsActive doesn't seem to be active so it just sends the regular key.
It's hard to reproduce because it's a bit random, but the more i add #If cm1.IsActive && WinActive("ahk_exe xxxx.exe") conditions, the more often it happens.
Here is a test code: (I am new at AHK, so I am probably not doing things right):
Code: Select all
#include Lib\AutoHotInterception.ahk
AHI := new AutoHotInterception()
id1 := AHI.GetKeyboardId(0x0C45, 0x7811, 1)
cm1 := AHI.CreateContextManager(id1)
return
#If cm1.IsActive && WinActive("ahk_exe apptest.exe")
Numpad0::msgbox test
#If
#If cm1.IsActive && WinActive("ahk_exe apptest1.exe")
Numpad0::msgbox test
#If
#If cm1.IsActive && WinActive("ahk_exe apptest2.exe")
Numpad0::msgbox test
#If
#If cm1.IsActive && WinActive("ahk_exe apptest3.exe")
Numpad0::msgbox test
#If
#If cm1.IsActive && WinActive("ahk_exe apptest4.exe")
Numpad0::msgbox test
#If
#If cm1.IsActive && WinActive("ahk_exe apptest5.exe")
Numpad0::msgbox test
#If
#If cm1.IsActive && WinActive("ahk_exe apptest6.exe")
Numpad0::msgbox test
#If
#If cm1.IsActive && WinActive("ahk_exe apptest7.exe")
Numpad0::msgbox test
#If
#If cm1.IsActive && WinActive("ahk_exe apptest8.exe")
Numpad0::msgbox test
#If
#If cm1.IsActive && WinActive("ahk_exe apptest9.exe")
Numpad0::msgbox test
#If
#If cm1.IsActive && WinActive("ahk_exe apptest0.exe")
Numpad0::msgbox test
#If
#If cm1.IsActive
Numpad0::msgbox test
#If
Code: Select all
213: Sleep,0
214: this.IsActive := state
215: }
---- C:\Users\Alex\Google Drive\Apps\AutoHotInterception\keypad_work.ahk
012: if cm1.IsActive && WinActive("ahk_exe apptest.exe")
016: if cm1.IsActive && WinActive("ahk_exe apptest1.exe")
020: if cm1.IsActive && WinActive("ahk_exe apptest2.exe")
---- C:\Users\Alex\Google Drive\Apps\AutoHotInterception\Lib\AutoHotInterception.ahk
213: Sleep,0
---- C:\Users\Alex\Google Drive\Apps\AutoHotInterception\keypad_work.ahk
024: if cm1.IsActive && WinActive("ahk_exe apptest3.exe")
---- C:\Users\Alex\Google Drive\Apps\AutoHotInterception\Lib\AutoHotInterception.ahk
214: this.IsActive := state
215: }
---- C:\Users\Alex\Google Drive\Apps\AutoHotInterception\keypad_work.ahk
028: if cm1.IsActive && WinActive("ahk_exe apptest4.exe")
032: if cm1.IsActive && WinActive("ahk_exe apptest5.exe")
036: if cm1.IsActive && WinActive("ahk_exe apptest6.exe")
040: if cm1.IsActive && WinActive("ahk_exe apptest7.exe")
044: if cm1.IsActive && WinActive("ahk_exe apptest8.exe")
048: if cm1.IsActive && WinActive("ahk_exe apptest9.exe")
052: if cm1.IsActive && WinActive("ahk_exe apptest0.exe")
057: if cm1.IsActive (0.08)
---- C:\Users\Alex\Google Drive\Apps\AutoHotInterception\Lib\AutoHotInterception.ahk
213: Sleep,0
214: this.IsActive := state
Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!
This is a known issue, adding more conditions to a #If statement increases the delay, and I *think* #if statements have a certain amount of time to resolve true or false before AHK just assumes false.
What you could try is to set a global variable to indicate which app is active, as that may resolve quicker (ie have a SetTimer checking active app and setting a variable accordingly)
If this does not work, then you could almost certainly fix it using Subscription Mode in AHI rather than Context Mode
I could maybe solve this by having AHI check for input more often - at the moment it does so once every ~15ms (The quickest I can do so with normal sleeps) - I do have some code to do this on a 1ms timer using MultiMedia timers, I could maybe port it into AHI and see if that solves your issue
What you could try is to set a global variable to indicate which app is active, as that may resolve quicker (ie have a SetTimer checking active app and setting a variable accordingly)
If this does not work, then you could almost certainly fix it using Subscription Mode in AHI rather than Context Mode
I could maybe solve this by having AHI check for input more often - at the moment it does so once every ~15ms (The quickest I can do so with normal sleeps) - I do have some code to do this on a 1ms timer using MultiMedia timers, I could maybe port it into AHI and see if that solves your issue
-
- Posts: 3
- Joined: 07 Oct 2019, 02:15
Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!
Thanks. I will have a look at subscription mode.
Is it possible to detect a 2 key-combination with it ?
Is it possible to detect a 2 key-combination with it ?
Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!
No, you would need to manually handle that yourself
Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!
v0.4.10 has been released!
Devices now poll at 1ms instead of ~15ms
This now means that if you are using a mouse set to 1000hz updates, AHK will be notified of mouse movement much more rapidly.
However, this may result in very high CPU load as AHK is not very suitable for this high a rate of input
@sharply-overcrowd Can you test if this makes Context Mode work better for you?
Devices now poll at 1ms instead of ~15ms
This now means that if you are using a mouse set to 1000hz updates, AHK will be notified of mouse movement much more rapidly.
However, this may result in very high CPU load as AHK is not very suitable for this high a rate of input
@sharply-overcrowd Can you test if this makes Context Mode work better for you?
-
- Posts: 3
- Joined: 07 Oct 2019, 02:15
Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!
Sorry but I can't install and work with AutoHotInterception … strange but true
I use Autohotkey_H (on Win10 64) and if i try Monitor.ahk have this:
I use Autohotkey_H (on Win10 64) and if i try Monitor.ahk have this:
Code: Select all
---------------------------
AutoHotkey
---------------------------
Error: CONTINUABLE EXCEPTION_ACCESS_VIOLATION
Mouse and Keyboard hooks have been disabled.
- Press yes to exit thread and continue execution.
- Press no to continue thread (debug).
- Press cancel to exit application.
Exception was caused in thread id: 7844
Line: 144
LineFile: C:\Program Files\AutoHotkey\Lib\AutoHotInterception.ahk
---------------------------
Sì No Annulla
---------------------------
Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!
Hello
I have successfully got my keyboards VID and PID. But I don't know how to detect which keyboard has send the keys. I need to know that because my goal is to change Windows keyboard layout into QWERTY if I use my QWERTY keyboard or into AZERTY layout if I use my AZERTY keyboard.
I have successfully got my keyboards VID and PID. But I don't know how to detect which keyboard has send the keys. I need to know that because my goal is to change Windows keyboard layout into QWERTY if I use my QWERTY keyboard or into AZERTY layout if I use my AZERTY keyboard.
Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!
This is brilliant - thanks so much! I have very quickly and easily shifted my setup to using your cool piece of software (see macro keyboard image attached) which I was previously accomplishing via LuaMacros+AHK. But, this is much cleaner and more elegant.
I have run into one issue though - the Pause/Break Key. Using the Monitor AHK you provided, if I press Pause/Break it shows Numlock(1/0 states)+LControl(4/5 states) and when I only press Numlock I get Numlock Keyname (just 0/1 states).
I am using Subscription mode. Do you know of any way I can differentiate between these two keys?
I have run into one issue though - the Pause/Break Key. Using the Monitor AHK you provided, if I press Pause/Break it shows Numlock(1/0 states)+LControl(4/5 states) and when I only press Numlock I get Numlock Keyname (just 0/1 states).
I am using Subscription mode. Do you know of any way I can differentiate between these two keys?
- Attachments
-
- IMG_1444.jpg (1.18 MiB) Viewed 7690 times
-
- Monitor.png (57.71 KiB) Viewed 7690 times
Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!
In AHI, you subscribe to a specific device, so inherently you know what device the input is coming from, because it's the one you subscribed to, so this comment makes absolutely no sensejvachez wrote: ↑14 Dec 2019, 12:50Hello
I have successfully got my keyboards VID and PID. But I don't know how to detect which keyboard has send the keys. I need to know that because my goal is to change Windows keyboard layout into QWERTY if I use my QWERTY keyboard or into AZERTY layout if I use my AZERTY keyboard.
Re: 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!
Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!
AHI v0.5.0 has been released!
Added SubscribeKeyboard and SubscribeMouseButtons to subscribe to all keys or buttons on a device
The old undocumented Monitor class has been removed, Monitor.ahk now uses the new SubscribeKeyboard / SubscribeMouseButtons functions
Added some development tools to help me track down and squash bugs with ScanCode differences between AHK and AHI
Added SubscribeKeyboard and SubscribeMouseButtons to subscribe to all keys or buttons on a device
The old undocumented Monitor class has been removed, Monitor.ahk now uses the new SubscribeKeyboard / SubscribeMouseButtons functions
Added some development tools to help me track down and squash bugs with ScanCode differences between AHK and AHI
Code: Select all
### Added
- SubscribeKeyboard and SubscribeMouseButtons can now be used to subscribe to all keys / buttons on a device
- Added ScanCodeTester Development Tool to investigate differences in AHI / AHK ScanCodes
### Changed
- Monitor.ahk now uses SubscribeKeyboard and SubscribeMouseButtons
Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!
Thanks!evilC wrote: ↑15 Dec 2019, 12:40Confirmed, this is a bug.
Raised issue: https://github.com/evilC/AutoHotInterception/issues/55
Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!
Hello evilC,
I'm posting to thank you, this is a great tool !
I had Bluetooth controllers designed for iOS/android in my drawers, they send things like arrow keys under windows and were therefore not useful. Now, I can take something like satechi st-arcm and do whatever I want with it.
One thing is strange with that particular BT controller though : one key (the bottom right one on the picture) is meant to go" home" on Android, and opens the default browser on Windows, but it is not intercepted. Not a big problem for me, but I was wondering how it can be, out of curiosity.
I'm posting to thank you, this is a great tool !
I had Bluetooth controllers designed for iOS/android in my drawers, they send things like arrow keys under windows and were therefore not useful. Now, I can take something like satechi st-arcm and do whatever I want with it.
One thing is strange with that particular BT controller though : one key (the bottom right one on the picture) is meant to go" home" on Android, and opens the default browser on Windows, but it is not intercepted. Not a big problem for me, but I was wondering how it can be, out of curiosity.
Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!
I can run my script, it is based on Subscription Example.ahk and works like w charm. But I would like to have a compiled version. When I run the compîled version I always get a msg :
"Unable to find lib\x64\interception.dll, exiting...
You should extract both x86 and x64 folders from the library folder in interception.zip into AHI's lib folder."
... but I have done that already and double-checked it.
I'm certainly missing something. Thank you
"Unable to find lib\x64\interception.dll, exiting...
You should extract both x86 and x64 folders from the library folder in interception.zip into AHI's lib folder."
... but I have done that already and double-checked it.
I'm certainly missing something. Thank you
Re: AutoHotInterception (AHI): Multi-Keyboard / Multi-Mouse support for AHK. Per-device blocking!
It's because of the way compiled scripts work, AHI was not designed to work with compiled scripts
I made some changes, I think it should work if you use this newer version of AutoHotInterception.ahk: https://raw.githubusercontent.com/evilC/AutoHotInterception/master/Lib/AutoHotInterception.ahk
I made some changes, I think it should work if you use this newer version of AutoHotInterception.ahk: https://raw.githubusercontent.com/evilC/AutoHotInterception/master/Lib/AutoHotInterception.ahk
Return to “Scripts and Functions (v1)”
Who is online
Users browsing this forum: wilkster and 34 guests