Advertisement
deadxxsmile

BudgetDeck LuaMacros Script

Aug 13th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.64 KB | None | 0 0
  1. -- This is a combo of several scripts and a bit of my own work to make a simple
  2. -- budget Streamdeck. Pressing a key on the numpad will instead type a set of keys
  3. -- designed to be set as a shortcut in a program like OBS or Streamlabs.
  4. -- Just take the key on the numpad, but add "ctrl+alt" to it to make the shortcut
  5. -- in your program of choice. IE: pressing 'Enter' on the numpad will send the key
  6. -- combo 'ctrl+alt+numpad enter' to the system.
  7. -- Credit to Taran Van Hemert for the code at the top that pulls the keyboards
  8. -- unique identifiers.
  9. -- Enjoy!
  10.  
  11. -- get luamacros HERE: http://www.hidmacros.eu/forum/viewtopic.php?f=10&t=241#p794
  12. -- plug in your 2nd keyboard, load this script into LUAmacros, and press the triangle PLAY button.
  13. -- Then, press any key on that keyboard to assign logical name ('budgetDeck') to macro keyboard
  14.  
  15. clear() -- clear the console from any previous runs
  16. lmc.minimizeToTray = true -- Minimizes LuaMacros to the tray to make things tidy
  17. local keyboardIdentifier = '0000AAA0' -- CHANGE THIS ONCE YOU KNOW THE RIGHT ONE!!
  18.  
  19. -- You need to get the identifier code for the keyboard with name "budgetDeck"
  20. -- This appears about halfway through the SystemID item and looks like 1BB382AF
  21. -- or some other alphanumeric combo. It's usually 7 or 8 characters long.
  22. -- Once you have this identifier, replace the value of keyboardIdentifier with it
  23.  
  24. --Don't ask for keyboard assignment help if the user has manually entered a keyboard identifier
  25. if keyboardIdentifier == '0000AAA0' then
  26.        lmc_assign_keyboard('budgetDeck');
  27. else lmc_device_set_name('budgetDeck', keyboardIdentifier);
  28. end
  29. --This lists connected keyboards
  30. dev = lmc_get_devices()
  31. for key,value in pairs(dev) do
  32.   print(key..':')
  33.   for key2,value2 in pairs(value) do print('  '..key2..' = '..value2) end
  34. end  
  35. print('You need to get the identifier code for the keyboard with name "budgetDeck"')
  36. print('Then replace the first 0000AAA value in the code with it. This will prevent having to manually identify keyboard every time.')
  37.  
  38. -- This is the code that intercepts the keypress, and sends the new key combo.
  39. lmc_set_handler('budgetDeck', function(button,direction)
  40.   if (direction == 1) then return end
  41.   if (button == 96) then
  42.     lmc_send_keys('%^{NUM0}', 50)
  43.     clear()
  44.     print('You Pressed: 0 ~ Which Is Button #' .. button .. ' ~ Sent: Ctrl+Alt+1')
  45.  
  46.   elseif (button == 97) then
  47.     lmc_send_keys('%^{NUM1}', 50)
  48.     clear()
  49.     print('You Pressed: 1 ~ Which Is Button #' .. button .. ' ~ Sent: Ctrl+Alt+1')
  50.  
  51.   elseif (button == 98) then
  52.     lmc_send_keys('%^{NUM2}', 50)
  53.     clear()
  54.     print('You Pressed: 2 ~ Which Is Button #' .. button .. ' ~ Sent: Ctrl+Alt+1')
  55.  
  56.   elseif (button == 99) then
  57.     lmc_send_keys('%^{NUM3}', 50)
  58.     clear()
  59.     print('You Pressed: 3 ~ Which Is Button #' .. button .. ' ~ Sent: Ctrl+Alt+1')
  60.  
  61.   elseif (button == 100) then
  62.     lmc_send_keys('%^{NUM4}', 50)
  63.     clear()
  64.     print('You Pressed: 4 ~ Which Is Button #' .. button .. ' ~ Sent: Ctrl+Alt+1')
  65.  
  66.   elseif (button == 101) then
  67.     lmc_send_keys('%^{NUM5}', 50)
  68.     clear()
  69.     print('You Pressed: 5 ~ Which Is Button #' .. button .. ' ~ Sent: Ctrl+Alt+1')
  70.  
  71.   elseif (button == 102) then
  72.     lmc_send_keys('%^{NUM6}', 50)
  73.     clear()
  74.     print('You Pressed: 6 ~ Which Is Button #' .. button .. ' ~ Sent: Ctrl+Alt+1')
  75.  
  76.   elseif (button == 103) then
  77.     lmc_send_keys('%^{NUM7}', 50)
  78.     clear()
  79.     print('You Pressed: 7 ~ Which Is Button #' .. button .. ' ~ Sent: Ctrl+Alt+1')
  80.  
  81.   elseif (button == 104) then
  82.     lmc_send_keys('%^{NUM8}', 50)
  83.     clear()
  84.     print('You Pressed: 8 ~ Which Is Button #' .. button .. ' ~ Sent: Ctrl+Alt+1')
  85.  
  86.   elseif (button == 105) then
  87.     lmc_send_keys('%^{NUM9}', 50)
  88.     clear()
  89.     print('You Pressed: 9 ~ Which Is Button #' .. button .. ' ~ Sent: Ctrl+Alt+1')
  90.  
  91.   elseif (button == 111) then
  92.     lmc_send_keys('%^{NUMDIVIDE}', 50)
  93.     clear()
  94.     print('You Pressed: / ~ Which Is Button #' .. button .. ' ~ Sent: Ctrl+Alt+1')
  95.  
  96.   elseif (button == 106) then
  97.     lmc_send_keys('%^{NUMMULTIPLY}', 50)
  98.     clear()
  99.     print('You Pressed: * ~ Which Is Button #' .. button .. ' ~ Sent: Ctrl+Alt+1')
  100.  
  101.   elseif (button == 109) then
  102.     lmc_send_keys('%^{NUMMINUS}', 50)
  103.     clear()
  104.     print('You Pressed: - ~ Which Is Button #' .. button .. ' ~ Sent: Ctrl+Alt+1')
  105.  
  106.   elseif (button == 107) then
  107.     lmc_send_keys('%^{NUMPLUS}', 50)
  108.     clear()
  109.     print('You Pressed: + ~ Which Is Button #' .. button .. ' ~ Sent: Ctrl+Alt+1')
  110.  
  111.   elseif (button == 110) then
  112.     lmc_send_keys('%^{NUMDECIMAL}', 50)
  113.     clear()
  114.     print('You Pressed: . ~ Which Is Button #' .. button .. ' ~ Sent: Ctrl+Alt+1')
  115.    
  116.   end
  117.  
  118. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement