LuaMacro blocking numpad for normal use

Announcements, questions
Post Reply
ErikderFreak
Posts: 4
Joined: 19 Apr 2021, 20:21

LuaMacro blocking numpad for normal use

Post by ErikderFreak » 19 Apr 2021, 21:13

So I made a macro to remap the function side of the numpad.
That works just fine.
But when I switch to the number side with NUMLOCK, pressing number keys just does nothing:
It won't write numbers, but the script also not works (wich is ofc intended)
So in some way the script blocks the writing of the number and I don't know why.
Here's my script:
--clear consol
clear()

--hide windows to tray
lmc.minimizeToTray = true
--lmc_minimize()

-- assign name to keyboard
lmc_device_set_name('numpad','2DD7D6F1')

--print devices (take out notations if wanted)
lmc_print_devices()

--select keyboard and remap buttons
lmc_set_handler('numpad', function(button,direction)
if (direction == 1) then return end
if (button == 36) then --numpad 7
lmc_send_keys('^+m', 50) --mute/unmute discord

elseif (button == 38) then --numpad 8
lmc_send_keys('^+d', 50) --input/output enable/disable discord

elseif (button == 37) then --numpad 4
lmc_send_keys('%a', 50) --wpe all

elseif (button == 12) then --numpad 5
lmc_send_keys('%s', 50) --wpe save-all

--elseif (button == 39) then --numpad 6
--to be assigned

elseif (button == 35) then --numpad 1
lmc_send_input(177, 0, 0) --previous track

elseif (button == 40) then --numpad 2
lmc_send_input(179, 0, 0) --play / pause

elseif (button == 34) then --numpad 3
lmc_send_input(176, 0, 0) --next track

elseif (button == 107) then --numpad +
lmc_send_input(175, 0, 0) --volume up

--elseif (button == 109) then --numpad -
--to be assigned
end
end
)

ErikderFreak
Posts: 4
Joined: 19 Apr 2021, 20:21

Re: LuaMacro blocking numpad for normal use

Post by ErikderFreak » 19 Apr 2021, 21:36

I found a quickfix, by just re-assigning all numbers to the numbers they are.
For example:
elseif (button == 103) then --numpad 7
lmc_send_input(103, 0, 0)

But I'm still wondering why it won't work without that.

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

Re: LuaMacro blocking numpad for normal use

Post by admin » 20 Apr 2021, 07:48

With lmc_set_handler used with 2 arguments you're assigning callback function for whole device - so all keys will be blocked. And your script is handling only the case with numlock off.
If you need to script only individual keys, add key number as agrument to lmc_set_handler.
See https://github.com/me2d13/luamacros/wiki/Triggers
Petr Medek
LUAmacros author

ErikderFreak
Posts: 4
Joined: 19 Apr 2021, 20:21

Re: LuaMacro blocking numpad for normal use

Post by ErikderFreak » 11 Nov 2021, 17:39

Oh, just realised I never replied that it worked! Thank you
Is there a way to mark this as solved?

Post Reply