button combination
button combination
Hello,
I am writing a script for my keyboard, and I am out off keys now.
I only need a few more, so using a extra keyboard is to mutch.
is there a possibility to hit a key combination to send a input?
if (button == 81) then lmc_send_input(49, 0, 0) -- press 1
lmc_send_input(49, 0, 2) -- release 1
elseif (button == 87) then lmc_send_input(50, 0, 0) -- press 2
lmc_send_input(50, 0, 0) -- release 2
Is there a way to push button 81 and 87, then send a input (or any other combi ofcourse)
------------------------------------------------------------------------------------------------------------
elseif (button == ???81 and 87???) then lmc_send_input(51, 0, 0) -- press 3
lmc_send_input(51, 0, 0) -- release 3
------------------------------------------------------------------------------------------------------------
Thank a lot,
Jack
I am writing a script for my keyboard, and I am out off keys now.
I only need a few more, so using a extra keyboard is to mutch.
is there a possibility to hit a key combination to send a input?
if (button == 81) then lmc_send_input(49, 0, 0) -- press 1
lmc_send_input(49, 0, 2) -- release 1
elseif (button == 87) then lmc_send_input(50, 0, 0) -- press 2
lmc_send_input(50, 0, 0) -- release 2
Is there a way to push button 81 and 87, then send a input (or any other combi ofcourse)
------------------------------------------------------------------------------------------------------------
elseif (button == ???81 and 87???) then lmc_send_input(51, 0, 0) -- press 3
lmc_send_input(51, 0, 0) -- release 3
------------------------------------------------------------------------------------------------------------
Thank a lot,
Jack
Re: button combination
This should be easy to implement using variable, shouldn't?
81 down -> set some variable e.g. shift = 1
81 up -> set some variable e.g. shift = 0
87: if (shift = 1) do action1 else do action2
81 down -> set some variable e.g. shift = 1
81 up -> set some variable e.g. shift = 0
87: if (shift = 1) do action1 else do action2
Petr Medek
LUAmacros author
LUAmacros author
Re: button combination
Hi thanks for the reply.
I found the "use of variable" topic.
I change a bit and I tried it, but it is not working like think it should be , but maybe I make a mistake.
when I start the script, it starts with shift on. but I want it to start with off. probably I just make a mistake.
when shift off normal caracters
when shift on, special caracters
I tried to find out this
do you have a example script ?
Thanks,
Jack
I found the "use of variable" topic.
I change a bit and I tried it, but it is not working like think it should be , but maybe I make a mistake.
Code: Select all
clear();
lmc_device_set_name('RIGHT', '2417B41')
--lmc.minimizeToTray = true
shift = true
alt = function()
if(shift) then
lmc_send_keys('Special')
else
lmc_send_keys('Normal')
end
end
shift = function()
if (shift) then
shift = false
else
shift = true
end
if(shift) then
print('shift is on')
else
print('shift is off')
end
end
lmc_set_handler('RIGHT',16,0,shift)
lmc_set_handler('RIGHT',18,0,alt)
when shift off normal caracters
when shift on, special caracters
I tried to find out this
but could not find out how the script for this should look like.This should be easy to implement using variable, shouldn't?
81 down -> set some variable e.g. shift = 1
81 up -> set some variable e.g. shift = 0
87: if (shift = 1) do action1 else do action2
do you have a example script ?
Thanks,
Jack
Re: button combination
When using lmc_set_handler for specific key (not whole keyboard) it has parameters:
- Device name
- Button number
- Direction 1 = down, 0 = up
- handler
Petr Medek
LUAmacros author
LUAmacros author
Re: button combination
Hi,
This is all new for me.
I try to find all the information on the internet and read it to learn this.
back to the button 81 an 87 Question,
This is what I made with the best understanding of your tips.
When I start the script first it dont work the corect way, when I hit the W key it sends a 3.
after I hit the Q key ones, the W key sends 2.
How to fix this??
When I hold down Q and hit W it send 3.... so that works.
What I can''t find out is how to send a 1 when I hit the Q button without also sending a 1 when I use Q in the QW combination.
How to fix this??
Thanks a lot for the tips.
Jack
This is all new for me.
I try to find all the information on the internet and read it to learn this.
back to the button 81 an 87 Question,
This is what I made with the best understanding of your tips.
Code: Select all
clear();
lmc_device_set_name('RIGHT', '2417B41')
--lmc.minimizeToTray = true
W = function()
if (Qdown) then
lmc_send_input(51, 0, 0)
lmc_send_input(51, 0, 2)
else
lmc_send_input(50, 0, 0)
lmc_send_input(50, 0, 2)
end
end
Qdown = function()
Qdown = true
end
Qup = function()
Qdown = false
end
lmc_set_handler('RIGHT',81,0,Qup)
lmc_set_handler('RIGHT',81,1,Qdown)
lmc_set_handler('RIGHT',87,0,W)
When I start the script first it dont work the corect way, when I hit the W key it sends a 3.
after I hit the Q key ones, the W key sends 2.
How to fix this??
When I hold down Q and hit W it send 3.... so that works.
What I can''t find out is how to send a 1 when I hit the Q button without also sending a 1 when I use Q in the QW combination.
How to fix this??
Thanks a lot for the tips.
Jack
Re: button combination
I think you need to go through some Lua tutorial if you want to use LuaMacros.
Your script has a few problems
- you're not initializing Qdown
- in global scope Qdown is function (not boolean) so your if doesn't work as you would expect
- setting Qdown in handler probably creates just local boolean variable (not a good idea to name handler function and boolean flag with the same name)
Without checking in LuaMacros I would try something like:
Your script has a few problems
- you're not initializing Qdown
- in global scope Qdown is function (not boolean) so your if doesn't work as you would expect
- setting Qdown in handler probably creates just local boolean variable (not a good idea to name handler function and boolean flag with the same name)
Without checking in LuaMacros I would try something like:
Code: Select all
clear();
lmc_device_set_name('RIGHT', '2417B41')
--lmc.minimizeToTray = true
QdownFlag = false
W = function()
if (QdownFlag) then
lmc_send_input(51, 0, 0)
lmc_send_input(51, 0, 2)
else
lmc_send_input(50, 0, 0)
lmc_send_input(50, 0, 2)
end
end
QdownHandler = function()
QdownFlag = true
end
QupHandler = function()
QdownFlag = false
end
lmc_set_handler('RIGHT',81,0,QupHandler)
lmc_set_handler('RIGHT',81,1,QdownHandler)
lmc_set_handler('RIGHT',87,0,W)
Petr Medek
LUAmacros author
LUAmacros author
-
- Posts: 14
- Joined: 19 Jul 2013, 12:43
Re: button combination
If I may suggest, look at from Macrorecorder, by Pavlov Andrew
https://github.com/mrsimb/macrorecorder
He uses a brilliant idea (so brilliant it took me a while to fully grasp it ) - he associates to each key an object that track its status, globally indexed so that it can be accessed by other key handlers.
He uses it to see if the modifiers are down, but it gives the status of any key, so the possibility is there to use any arbitrary key as modifier.
Beware, however, of hardware limitations in that case...
The modifiers are different from normal keys in that they do not send the "down" code while they are kept pressed, as all other keys do.
As a result, you usually cannot have more than two "normal" keys pressed at the same time...
https://github.com/mrsimb/macrorecorder
He uses a brilliant idea (so brilliant it took me a while to fully grasp it ) - he associates to each key an object that track its status, globally indexed so that it can be accessed by other key handlers.
He uses it to see if the modifiers are down, but it gives the status of any key, so the possibility is there to use any arbitrary key as modifier.
Beware, however, of hardware limitations in that case...
The modifiers are different from normal keys in that they do not send the "down" code while they are kept pressed, as all other keys do.
As a result, you usually cannot have more than two "normal" keys pressed at the same time...
Re: button combination
Hi Cristiano,
I tried Macro Recorder but it seems not to be working
My keyboard is a Cherry hooked to an MSI CR70 laptop. The OS is Win7 64-bit.
I launched luamacro.exe, loaded the macro and scanned the devices.
It ended by the following lines:
====================================
2018-09-08 18:25:50:746 [LUA] ERROR: Device with name ff&0& not found
using your_customized_keypad_id
2018-09-08 18:25:50:746 [LUA] ERROR: Device with name your_customized_keypad_id not found
using 92&0&
<unassigned> : \\?\HID#VID_04F2&PID_0116#7&310526FF&0&0000#{884B96C3-56EF-11D1-BC8C-00A0C91405DD} [4000363] : keyboard
90&0& : \\?\HID#{00001124-0000-1000-8000-00805F9B34FB}_VID&00020103_PID&0204&COL01#9&C598690&0&0000#{884B96C3-56EF-11D1-BC8C-00A0C91405DD} [131231] : keyboard
85&0& : \\?\HID#VID_1038&PID_1702&MI_01&COL02#8&27785D85&0&0001#{884B96C3-56EF-11D1-BC8C-00A0C91405DD} [65601] : keyboard
<unassigned> : \\?\ACPI#PNP0303#4&202E1355&0#{884B96C3-56EF-11D1-BC8C-00A0C91405DD} [720959] : keyboard
Total number of devices: 4
====================================
The Device Manager tells me that the <unassigned> first keyboard is the Cherry.
No macro seems to be recorded using the described procedure from Github.
I'm even wondering where the registered macro should be displayed !
Do you have any clue ?
Thanks in advance, regards
I tried Macro Recorder but it seems not to be working
My keyboard is a Cherry hooked to an MSI CR70 laptop. The OS is Win7 64-bit.
I launched luamacro.exe, loaded the macro and scanned the devices.
It ended by the following lines:
====================================
2018-09-08 18:25:50:746 [LUA] ERROR: Device with name ff&0& not found
using your_customized_keypad_id
2018-09-08 18:25:50:746 [LUA] ERROR: Device with name your_customized_keypad_id not found
using 92&0&
<unassigned> : \\?\HID#VID_04F2&PID_0116#7&310526FF&0&0000#{884B96C3-56EF-11D1-BC8C-00A0C91405DD} [4000363] : keyboard
90&0& : \\?\HID#{00001124-0000-1000-8000-00805F9B34FB}_VID&00020103_PID&0204&COL01#9&C598690&0&0000#{884B96C3-56EF-11D1-BC8C-00A0C91405DD} [131231] : keyboard
85&0& : \\?\HID#VID_1038&PID_1702&MI_01&COL02#8&27785D85&0&0001#{884B96C3-56EF-11D1-BC8C-00A0C91405DD} [65601] : keyboard
<unassigned> : \\?\ACPI#PNP0303#4&202E1355&0#{884B96C3-56EF-11D1-BC8C-00A0C91405DD} [720959] : keyboard
Total number of devices: 4
====================================
The Device Manager tells me that the <unassigned> first keyboard is the Cherry.
No macro seems to be recorded using the described procedure from Github.
I'm even wondering where the registered macro should be displayed !
Do you have any clue ?
Thanks in advance, regards
Re: button combination
answering to myself, after a thorough reading session of the forum, I ended with my first recorded macro.
Had to create an empty macro.lua file first then give a logical name to my added keyboard.
By the way, nice and very hopeful program for my application.
Regards
Had to create an empty macro.lua file first then give a logical name to my added keyboard.
By the way, nice and very hopeful program for my application.
Regards
-
- Posts: 14
- Joined: 06 Feb 2018, 05:23
Re: button combination
For the key combination, I find a nice wrapper for Luamacros by PotentiumRLX.
https://www.youtube.com/watch?v=LsHhLZXrQsI
["81, 87, 69"] = function()
print("This is a test to show that LuaMacros works with key combinations.");
end;
The combination of the buttons can be implemented by an array of "["81, 87, 69"]"
https://www.youtube.com/watch?v=LsHhLZXrQsI
["81, 87, 69"] = function()
print("This is a test to show that LuaMacros works with key combinations.");
end;
The combination of the buttons can be implemented by an array of "["81, 87, 69"]"