Original key still being sent?

Announcements, questions
Post Reply
SifJar
Posts: 5
Joined: 12 Jan 2016, 13:55

Original key still being sent?

Post by SifJar » 12 Jan 2016, 14:01

So I'm very new to this, used Lua a little before years ago (can't remember any of it now though). I have written the following script:

Code: Select all

lmc_device_set_name('tablet', 'GDIX1001')
lmc_print_devices()

lmc_set_handler('tablet',function(button, direction)
 if (button == 91) then print ('pressed')
 end
end) 
The code functions largely as expected; the list of devices has the correct device named "tablet", the callback catches the button press and prints "pressed" in the output window (although it is printed twice for each press; once for the down event and once for the up event?). However, the original keystroke is also still sent. I'm essentially trying to disable a particular key (Windows key on a tablet), while still allowing the key to function on other keyboards etc. But when I run the above script, the Windows key is still registering as being pressed (Start menu appears). How do I block this? What's wrong with my code?

Thanks.

EDIT: Upon further testing, I believe this issue may only apply to the Windows key. Using similar code with a different keyboard, I can block a button just fine:

Code: Select all

clear()
--lmc_device_set_name('tablet', 'GDIX1001')
lmc_assign_keyboard('tablet')
lmc_print_devices()

lmc_set_handler('tablet',string.byte('H'),1,function()
 print ('pressed')
 --end
end)
I have tested both pieces of code on both Windows 7 and 10, with the same results on each in both cases.

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

Re: Original key still being sent?

Post by admin » 13 Jan 2016, 09:00

Blocking the original key press is kind of windows hack.
It's quite possible that this hack I have chosen doens't work for windows key.
But I don't see other way how to block original key press so this is probably a fact - LuaMacros cannot block windows key.
Petr Medek
LUAmacros author

SifJar
Posts: 5
Joined: 12 Jan 2016, 13:55

Re: Original key still being sent?

Post by SifJar » 13 Jan 2016, 15:26

admin wrote:Blocking the original key press is kind of windows hack.
It's quite possible that this hack I have chosen doens't work for windows key.
But I don't see other way how to block original key press so this is probably a fact - LuaMacros cannot block windows key.
Ah, that's frustrating. Oh well. Would it be possible to instead of completely blocking the key, have LuaMacros send it as Ctrl + LWin? It seems like this would work as a workaround, Windows doesn't seem to do anything when pressing the combination of both keys.

I'm thinking this should probably be possible, but I'm not completely sure how to proceed. Obviously I need it to send Ctrl+LWin *instead* of just LWin, not as well as LWin on it's own. I don't know if just sending Ctrl whenever LWin is pressed would work?

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

Re: Original key still being sent?

Post by admin » 14 Jan 2016, 08:48

I don't think so, that would be even more complicated. The issue is windows probably have some special API to handle window key and LuaMacros blocking mechanism doesn't work with this special way. Once I would investigate and see the possibilities it would be easier to block the key completely than adding additional key press. But I'm not sure that is doable and don't want to spend time with investigation because of one key...
Petr Medek
LUAmacros author

SifJar
Posts: 5
Joined: 12 Jan 2016, 13:55

Re: Original key still being sent?

Post by SifJar » 14 Jan 2016, 16:42

admin wrote:I don't think so, that would be even more complicated. The issue is windows probably have some special API to handle window key and LuaMacros blocking mechanism doesn't work with this special way. Once I would investigate and see the possibilities it would be easier to block the key completely than adding additional key press. But I'm not sure that is doable and don't want to spend time with investigation because of one key...
I completely understand you don't want to spend time investigating. My initial thought is it should be doable, as AutoHotKey can block the Windows key, presumably using some API to do so. It just can't tell what keyboard it's coming from :P However, I'm not overly familiar with Windows APIs, or how either LuaMacros or AHK work internally, so I'm guessing it's probably not as simple as it seems in my mind. I guess I'll just have to accept what I want isn't possible (right now, at the very least).

Post Reply