I would like to make a Macro-Keyboard

Announcements, questions
Post Reply
Trit
Posts: 5
Joined: 16 Jan 2018, 14:24

I would like to make a Macro-Keyboard

Post by Trit » 16 Jan 2018, 14:46

Hello,

I made a keyboard like that : http://www.instructables.com/id/Making- ... -less-tha/
It worked well with HIDMacros.

Since a windows update :(
My HIDMacros now doesn't work on my computer.

So I would like to do the same thing with LuaMacros but I don't know programming language...
I started to try anyway by testing the quick start code :

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 == string.byte('C')) then lmc_spawn("calc")
  elseif (button == string.byte('N')) then lmc_spawn("notepad", "C:\\test.txt")
  elseif (button == string.byte('H')) then lmc_send_keys('Hello world')
  else print('Not yet assigned: ' .. button) 
  end
end)
I replace "C" "N" "H" by "1" "2" "3" because my external keyboard is a numpad.
I pressed the start button
and fonctions are not called when I press "1" "2" or "3".

I would be very happy If you can send me a code for that. If I have just to replace the caracters I need for my shortcuts...

Thanks in advance for your help.
Trit

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

Re: I would like to make a Macro-Keyboard

Post by admin » 17 Jan 2018, 08:53

If you do not know scripting you can't effectively use LuaMacros, I'm sorry.

You may give a chance to GUI that Cris announced recently - see http://www.hidmacros.eu/forum/viewtopic.php?f=10&t=570

You modifications should be ok, when you run the script you should get popup window to identify keyboard for macros. After pressing any kay on that keyboard you should get the funcinality - starting calculator or sending some text to active window
Petr Medek
LUAmacros author

Trit
Posts: 5
Joined: 16 Jan 2018, 14:24

Re: I would like to make a Macro-Keyboard

Post by Trit » 17 Jan 2018, 11:03

Thank you,

- I would like to try the GUI from Cris but I don't know how to open it, I don't find executable file when extracted.

- I tried again your script like that :

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 == string.byte('.')) then lmc_send_keys('Hello world')
  elseif (button == string.byte('2')) then lmc_send_keys('Hello world')
  elseif (button == string.byte('1')) then lmc_send_keys('Hello world')
  elseif (button == string.byte('*')) then lmc_send_keys('Hello world')
  elseif (button == string.byte('/')) then lmc_send_keys('Hello world')
  elseif (button == string.byte(' ')) then lmc_send_keys('Hello world')
  elseif (button == string.byte('+')) then lmc_send_keys('Hello world')
  elseif (button == string.byte('-')) then lmc_send_keys('Hello world')
  else print('Not yet assigned: ' .. button)
  end
end)    
It works ! But only with the space button :(

Also, when I release the "num lock" and I press the "0" (now insert) and the "." (now del), It give me "Hello world"...

Thanks

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

Re: I would like to make a Macro-Keyboard

Post by admin » 18 Jan 2018, 08:46

Remove all the conditions, see the number in "Not yet assigned" message and use that number directly in ifs, without string.byte.
Petr Medek
LUAmacros author

Trit
Posts: 5
Joined: 16 Jan 2018, 14:24

Re: I would like to make a Macro-Keyboard

Post by Trit » 18 Jan 2018, 10:58

Yess ! It works, thank you very much !

Trit
Posts: 5
Joined: 16 Jan 2018, 14:24

Re: I would like to make a Macro-Keyboard

Post by Trit » 18 Jan 2018, 17:14

A last thing :

With HIDMacros, I just had to launch it and it worked.

I registred the script to "myscript.lua" and I can open it directly
but I would like the script to start automaticaly and my external keyboard to be recognised automaticaly.
Is it possible ?

Thanks in advance,
Trit

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

Re: I would like to make a Macro-Keyboard

Post by admin » 19 Jan 2018, 08:32

Petr Medek
LUAmacros author

Trit
Posts: 5
Joined: 16 Jan 2018, 14:24

Re: I would like to make a Macro-Keyboard

Post by Trit » 19 Jan 2018, 11:44

Thank you very much ! It works very well :)

Here is my code :

I start with this batch file :

Code: Select all

start /MIN C:\luamacros\luamacros.exe C:\luamacros\myscript.lua -r
exit
And here is my lua script (myscript.lua) :

Code: Select all

--start minimized
lmc_minimize()

-- assign logical name to my external keyboard
lmc_device_set_name ('SKP', '1A2C&PID');

-- define callback for whole device
lmc_set_handler('SKP',function(button, direction)
  if (direction == 1) then return end  -- ignore down
  if     (button == 96) then lmc_send_keys('m')
  elseif (button == 32) then lmc_send_keys('p')
  elseif (button == 110) then lmc_send_keys('l')
  elseif (button == 13) then lmc_send_keys(' ')
  elseif (button == 97) then lmc_send_keys('q')
  elseif (button == 98) then lmc_send_keys('j')
  elseif (button == 99) then lmc_send_keys('t')
  elseif (button == 100) then lmc_send_keys('s')
  elseif (button == 101) then lmc_send_keys('f')
  elseif (button == 102) then lmc_send_keys('d')
  elseif (button == 107) then lmc_send_keys('g')
  elseif (button == 103) then lmc_send_keys('r')
  elseif (button == 104) then lmc_send_keys('c')
  elseif (button == 105) then lmc_send_keys('a')
  elseif (button == 109) then lmc_send_keys('u')
  elseif (button == 111) then lmc_send_keys('y')
  elseif (button == 106) then lmc_send_keys('b')
  elseif (button == 8) then lmc_send_keys('w')
  else print('Not yet assigned: ' .. button)
  end
end)
---

To find my keyboard id, I used :

Code: Select all

lmc_assign_keyboard('MACROS');
lmc_print_devices()
Thanks again,
Have a good day,
Trit

ender
Posts: 1
Joined: 25 Jun 2018, 08:23

Re: I would like to make a Macro-Keyboard

Post by ender » 25 Jun 2018, 08:24

Thanks for the code, Trit!
Hey, what's up? I'm learning how to win at la vuelta a Espana 2018. You know, I'm always in the mood to fight. And fun is always here. Just check for yourself.

Post Reply