Request: holding key down

What features you would like to have in HIDmacros?
Post Reply
Wesha
Posts: 1
Joined: 03 Apr 2011, 01:21

Request: holding key down

Post by Wesha » 03 Apr 2011, 01:25

I have a foot pedal that is a HID "keyboard". hidmacros works perfectly with it except for one little thing...

What I need is for that pedal (that is equiavalent to key "1" on the keyboard) to be completely remapped to another key on the keyboard (say, "W"). By "completely", I mean that I don't want it to *activate* a macro; when I press the pedal and hold it down, I want Windows to believe that I pressed and am holding down "W" key on the keyboard.

Think it is possible?

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

Re: Request: holding key down

Post by admin » 04 Apr 2011, 08:33

Currently it's not possible. For keyboard you can define macro only on key press.
For game device buutons (joystick, gamepad) you can define different macro for up and down event, but anyway there's no script command to send only key down or key up message.
So I keep it as feature request which may be added in the future...
Petr Medek
LUAmacros author

AnnaV
Posts: 8
Joined: 17 Jan 2019, 20:41

Re: Request: holding key down

Post by AnnaV » 19 Jan 2019, 01:05

I'd like to second this request. On multiple occasions I'd need to hold down a key, currently only possible to send single keys.
(The game I'm playing distinguishes between different functions via single key, or long-press. For example tapping "n" brings down landing gear, but holding down "n" activates auto-land feature.) I'm trying to map this functionality to a game device (Thrustmaster MFD Cougar) and at least I don't think this is currently possible.

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

Re: Request: holding key down

Post by admin » 21 Jan 2019, 09:35

This is now possible in luamacros, using lmc_send_input you can send only key press or key release.
But for luamacros you need to deal with lua scripting.
Petr Medek
LUAmacros author

I3ordo
Posts: 16
Joined: 01 Oct 2018, 06:58

Re: Request: holding key down

Post by I3ordo » 05 Nov 2019, 04:01

Can you give a line of example for "lmc_send_input" usage?

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

Re: Request: holding key down

Post by admin » 05 Nov 2019, 08:56

Did you search this forum?
Petr Medek
LUAmacros author

I3ordo
Posts: 16
Joined: 01 Oct 2018, 06:58

Re: Request: holding key down

Post by I3ordo » 05 Nov 2019, 16:53

Yes, i searched and found this post viewtopic.php?f=4&t=3727 which shows

Code: Select all

  if (button == 18) then -- if ALT
    if (direction == 1) then lmc_send_input(91, 0, 0) -- press WIN
    elseif (direction == 0) then lmc_send_input(91, 0, 2) -- release WIN
    end
  elseif (button == 91) then -- if WIN
    if (direction == 1) then lmc_send_input(18, 0, 0) -- press ALT
    elseif (direction == 0) then lmc_send_input(18, 0, 2) -- release ALT
    end
so i thought, since the "ALT" key will always be send to system no matter what,and that key is best for a "pushToTalk" key (ergonomically)

for my keypadImage

i thought i should send the "ALT+NUMPLUS" on ALT pressing
and "ALT+NUMMINUS" on ALT release.
the keycode that appears(in HDmacro's test area) when i press NUMPLUS is "189" and "223" for "NUMMINUS"

so this code come up to my mind.

Code: Select all

                 --NUMPLUS = 189 / NUMMINUS = 223
                 if (button == 18 and direction ==1) then --if ALT is pressed
                 lmc_send_input(189, 0, 0)--send "NUMPLUS press" which should result in ALT+NUMPLUS
                 elseif (direction ==0) then --
                 lmc_send_input(189, 0, 2) --send "NUMPLUS release"
                 end    
But it does nothing and not give syntax for invalid errors. Ideally, i want it to send ALT+NUMPLUS on press and ALT+NUMMINUS on release.
These keys are meant for OBS and they make the camera appear and vanish. the send_keys function starts repeating.
I turned off repeating keys but hoping for a solution that does not require that. repeating keys, turns out to be awesome...

Update:
Well i could not solve the problem through lmc_sendinput but instead, by chance, after many hours or trial and error, i accidentally found it that, instead of using a special combination; for HOLDing a key without disabling repeating keys from windows completely, i used "ALT+V" by pressing and hoding them natively with my own fingers, and letting the luamacros, send a "+F13" on release., so alt+v does not repeat , does not interfere with anything i know of, and shift+13 for the out action that changes the scene.

Code: Select all

--V--^+%
       elseif (button == 86 and direction ==0) then
              lmc_send_keys('+{F13}', 50) 
https://youtu.be/RISO1Yz33IM

Post Reply