Thanks a lot. Turns out, the homework software I'm using only requires me to type
sqrt without the
\ and brackets to work. Everything else went smoothly. I can automatically call both parentheses, and exponentiate. Here's the code for anybody who wants to use it for themselves if they stumble upon this thread.
Code: Select all
-- assign logical name to macro keyboard
lmc_assign_keyboard('MACROS');
-- define callback for whole device
lmc_set_handler('MACROS',function(button, direction)
if (direction == 1) then return end -- ignore down
if (button == 97) then lmc_send_keys('sec(')
elseif (button == 98) then lmc_send_keys('csc(')
elseif (button == 99) then lmc_send_keys('cot(')
elseif (button == 100) then lmc_send_keys('sin(')
elseif (button == 101) then lmc_send_keys('cos(')
elseif (button == 102) then lmc_send_keys('tan(')
elseif (button == 103) then lmc_send_keys('log(')
elseif (button == 104) then lmc_send_keys('ln(')
elseif (button == 105) then lmc_send_keys('pi')
elseif (button == 13) then lmc_send_keys('/')
elseif (button == 107) then lmc_send_keys('sqrt')
elseif (button == 109) then
lmc_send_input(16, 0, 0) -- press shift
lmc_send_input(54, 0, 0) -- press 6
lmc_send_input(54, 0, 2) -- release 6
lmc_send_input(16, 0, 2) -- release shift, types ^
elseif (button == 111) then
lmc_send_input(16, 0, 0) -- press shift
lmc_send_input(57, 0, 0) -- press 9
lmc_send_input(57, 0, 2) -- release 9
lmc_send_input(16, 0, 2) -- release shift, types (
elseif (button == 106) then
lmc_send_input(16, 0, 0) -- press shift
lmc_send_input(48, 0, 0) -- press 0
lmc_send_input(48, 0, 2) -- release 0
lmc_send_input(16, 0, 2) -- release shift, types )
else print('Not yet assigned: ' .. button)
end
lmc.minimizeToTray = true
end)
The last little bit just minimizes the program to the tray as per the instructions here:
http://www.hidmacros.eu/forum/viewtopic.php?f=12&t=270 It was something that I really liked from HIDMacros, and I'm glad I can use it with Lua too.
There are a few last quality of life things I want to work on, but this is the code that as far as I'm aware, anybody with a cheap numpad can use. Thanks to u/Trit for their attempt that I could piggyback off of (
http://www.hidmacros.eu/forum/viewtopic.php?f=10&t=574), and most of all, thanks to Petr for not only helping me out here, but also for making such a great program!
