REQUEST: KeyDown / KeyUp support

What features you would like to have in HIDmacros?
Post Reply
iam
Posts: 5
Joined: 06 Apr 2011, 20:59

REQUEST: KeyDown / KeyUp support

Post by iam » 09 Apr 2011, 16:51

Hi Petr,

If you could consider adding support for KeyUp/KeyDown events, that would be great.
It would make it very easy to deal with key hold down situations with toggle switches on a "keyboard hack".

If I could write scripts such as the following one, it would solve most of my problems:

(Routines)

Code: Select all

dim gkeydownFlag
gkeydownFlag = false
(Script for g key)

Code: Select all

if HIDmacros.keydown then
  if gkeydownFlag = false then
    gkeydownFlag = true
    sendkeys "g"
  end if
end if

if HIDmacros.keyup then
  gkeydownFlag = false
end if
So when holding down the g key, on the first g keypress event, HIDmacro would send "g" and set the gkeydownFlag to true.
On future keypress event, since the gkeydownFlag would be set to true, HIDmacros would not send anything.
When releasing the g key, HIDmacro would set the gkeydownFlag to false, so that it can send "g" again on the next keypress event.


What do you think?

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

Re: REQUEST: KeyDown / KeyUp support

Post by admin » 11 Apr 2011, 07:58

Hmm, you can do this already with game device button. There you can define macro for down & up event.
I may add something similar also for keyboard, but there are some problems when you want to use keyboard for toggle switches. Keyboard driver repeats KEY_DOWN message (when not turned off for whole Windows) and some applications can have problems when several keys on keyboard are down...
Petr Medek
LUAmacros author

ocf81
Posts: 5
Joined: 19 Jan 2013, 21:36

Re: REQUEST: KeyDown / KeyUp support

Post by ocf81 » 20 Jan 2013, 17:02

I'd like to bump this feature request, and perhaps extend it a little.

HIDMacros.sendKeyDownEvent("^<")
sleep(300)
HIDMacros.sendKeyDownEvent("+<")
sleep(300)
HIDMacros.sendKey({NUM1})
sleep(150)
HIDMacros.sendKeyUpEvent("+<")
sleep(150)
HIDMacros.sendKeyUpEvent("^<")

It seems that at the moment, HIDMacros is only using the KeyPressed events.

The reason I don't want a game device for this is that a game device has a maximum of 32 buttons and will cost me a lot of money, whereas a keyboard has many keys and only costs a couple of Euros.

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

Re: REQUEST: KeyDown / KeyUp support

Post by admin » 21 Jan 2013, 08:17

But this seems to be something different.
The request here was to add support for down&up keyboard event as macro trigger. Your code example (if I understand it right) asks for down&up message support as macro/script action.
What would be a purpose of this feature? If you get my interest, I may have a look sooner :-).
If I remember well I decided to use API function that sends complete keystrokes because it had better behavior (compatible with more apps) than sending DOWN & UP API message manually...
Petr Medek
LUAmacros author

ocf81
Posts: 5
Joined: 19 Jan 2013, 21:36

Re: REQUEST: KeyDown / KeyUp support

Post by ocf81 » 21 Jan 2013, 20:28

DCS A-10 has an onboard computer which is a bit finicky to operate with the mouse in the 3D pit. DCS needs a little delay between keystrokes. As I understand it, sendkeysslow sends the keyups of modifiers before the keystrokes, so that won't work for me. Hence the request. :-)

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

Re: REQUEST: KeyDown / KeyUp support

Post by admin » 22 Jan 2013, 08:08

No, sendkeysslow is doing exactly the thing you were asking with your script example. Putting delays between modifier down, key and modifier up.
As discussed in appropriate topic http://hidmacros.eu/forum/viewtopic.php?f=5&t=28 it's also mentioned that it didn't help for DCS. So I doubt adding key down+up as command would solve something...
Petr Medek
LUAmacros author

Post Reply