Internals: How do you block the original key event?

Announcements, general discussion
Post Reply
foobar
Posts: 2
Joined: 19 Oct 2013, 21:24

Internals: How do you block the original key event?

Post by foobar » 19 Oct 2013, 21:31

Hello,

I am trying to do something similar to what HID Macros does, but with Autohotkey and AHKHID.

Unfortunately I have not found a way to block the original Key Event yet.
When listening to WM_INPUT you can't seem to block the key event from reaching the focused window, using a low level system hook like WH_KEYBOARD_LL/LowLevelKeyboardProc you can block, but you can't differentiate between different HID devices, as far as I know.

How do you do this in your application?

Thanks a lot for the help! Great application!

admin
Site Admin
Posts: 451
Joined: 01 Nov 2010, 13:00
Location: Prague, Czech republic
Contact:

Re: Internals: How do you block the original key event?

Post by admin » 21 Oct 2013, 08:13

See last FAQ
Petr Medek
LUAmacros author

foobar
Posts: 2
Joined: 19 Oct 2013, 21:24

Re: Internals: How do you block the original key event?

Post by foobar » 22 Oct 2013, 01:16

Oh, well I already read the FAQ, that is why I asked for advice as you proposed:
Feel free to ask me what's inside and how does it work, but I spent several hours (or nights :-) tuning all API functions and calls. If you go in the same way, I can advice.

admin
Site Admin
Posts: 451
Joined: 01 Nov 2010, 13:00
Location: Prague, Czech republic
Contact:

Re: Internals: How do you block the original key event?

Post by admin » 22 Oct 2013, 07:32

I think it's mentioned in that topic.
I have memory mapped file for communication between raw input handling and keyboard hook. So code listening to row input message receives message and stores keyboard and key code into memory. When keyboard hook injected to active application receives regular keyboard message it uses memory mapped file to ask hidmacros whether the key should be blocked or not. Hidmacros know if there's some macro defined for keyboard/key combination and if so it answers through shared memory and regular keyboard message is blocked in the hook - never reach target (active) application.
Hope it helps a bit
Petr Medek
LUAmacros author

ds3d
Posts: 1
Joined: 14 Mar 2014, 08:24

Re: Internals: How do you block the original key event?

Post by ds3d » 14 Mar 2014, 08:33

Hi. Thanks for this util. I do not understand much of these programming technical tums.
And I am trying to find a simple solution for my issue.
I have a usb numeric keypad I want to use for Blender 3D app shortcuts.
I have mapped the + on the keypad with the - HIDMacros.SendKeys "^z" - to get the undo in Blender.
I get the undo but it also zooms in (the + keys original hotkey).
Please, I would appreciate the advice how to block the zoom (original) function.
After that I can map the entire thing and work with it.
Thank you.

flyguy
Posts: 3
Joined: 03 Sep 2013, 15:27

Re: Internals: How do you block the original key event?

Post by flyguy » 19 Apr 2014, 07:27

basically, we are looking for a way to block the original button function.

For example, we want to make the "right click" send a keystroke "k".

But we do not want the right click to happen, only the "k" to happen.

We need to DISABLE the right click, and to allow only the "k" keystroke.

Right now, HID Macros is sending BOTH the right click and the "k" keystroke. But we need to STOP the right click, and send only the "k".

can it be done?

admin
Site Admin
Posts: 451
Joined: 01 Nov 2010, 13:00
Location: Prague, Czech republic
Contact:

Re: Internals: How do you block the original key event?

Post by admin » 22 Apr 2014, 07:38

Hmm, consider mouse macros being more "experimental feature". I introduced this funcionality
a) to use mouse wheel
b) to support toggle switches
For a) it may work with some small limitations (in some situations I'm not able to block original wheel message completely)
for b) there were problems till the beginning so I decided to use DirectX devices (joysticks) for toggle switches.
Petr Medek
LUAmacros author

thjakob
Posts: 4
Joined: 03 Mar 2017, 21:05

Re: Internals: How do you block the original key event?

Post by thjakob » 05 Mar 2017, 11:52

Hello Petr,

First of all - greate work!
(I was searching for distinguish barcode scanner input (that connects as normal HID device) from keyboard input - because I`like to do something else with the barcode...)

With your greate programm it works - but from time to time the hook is released - and the barcode input is passed as normal input again (so I have to restart luamacros)
Luamacros itselvs seams to work all the time - the barcode input is detected correctly all the time. The only thing is, that eg. after having locked the pc the `hook` doesn't work anymore and luamacros grab the scanner input, but the scanner input also is passed as normal keyboard input to windows too.

Is there a solution (what do I wrong)?
How to detect, if the `hook` is still working?

Thank you
Thomas

admin
Site Admin
Posts: 451
Joined: 01 Nov 2010, 13:00
Location: Prague, Czech republic
Contact:

Re: Internals: How do you block the original key event?

Post by admin » 06 Mar 2017, 09:06

Thanks.
Hard to say. Maybe you can turn on verbose logging and see (after losing the funcionality) if logs says something different or interesting.

Code: Select all

lmc_log_all();
lmc_log_spool('this_will_be_long.log')
Petr Medek
LUAmacros author

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests