Author Topic: Send Keypress When Pressing (and Holding) Another Key  (Read 1541 times)

Starblue7

  • Full Member
  • ***
  • Posts: 131
Send Keypress When Pressing (and Holding) Another Key
« on: March 02, 2023, 04:52:05 PM »
For the life of me, I'm trying to get this to work.

I have a command combination on the keyboard where when I press and hold the W key, I want it to play a sound and also press a different key once.  All while holding down the original W key.

No matter what I try, VoiceAttack will play the sound, but it won't initiate the target keypress while I have the W key held down.

Is there some setting I'm missing or some elaborate way to accomplish this?

When I press key:  W
Execute: Play Sound and Press NumPad Multiply Key and hold for .01 seconds and release.

Adjusting the HOLD for the NumPad key above doesn't make any difference.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Send Keypress When Pressing (and Holding) Another Key
« Reply #1 on: March 02, 2023, 05:14:35 PM »
Which application are you testing this with? Does it work in Notepad?


On my machine, with multiple configurations ("Do not allow key to be passed through" checked/unchecked, "Shortcut is invoked when long-pressed" checked/unchecked) it does work.

Starblue7

  • Full Member
  • ***
  • Posts: 131
Re: Send Keypress When Pressing (and Holding) Another Key
« Reply #2 on: March 02, 2023, 05:23:45 PM »
This issue is, by holding down the W key it allows for forward movement in the game.
Which, WASD is standard amongst a very large majority of games for movement.

So, I need the constant W being sent to the game in order to keep movement, so I can't enabled:
'Do not allow key to be passed through'  in the VoiceAttack settings.

What I need is that when I press and hold the W key, it kicks off sending a key command once while this is happening.
It won't do it unless I release the W key (Although it WILL play the sound).

Even with only the 'Shortcut is invoked when long-pressed' is checked, it still won't happen.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Send Keypress When Pressing (and Holding) Another Key
« Reply #3 on: March 02, 2023, 05:31:07 PM »
Does the command produce the expected character output ("w" followed by "*", then more "w" characters) in Notepad?


If you disable keyboard shortcuts using the button (the keyboard icon) on VoiceAttack's main window, physically hold down the W key on your keyboard, and then physically press the numpad multiply key on your keyboard, does that work?

Starblue7

  • Full Member
  • ***
  • Posts: 131
Re: Send Keypress When Pressing (and Holding) Another Key
« Reply #4 on: March 02, 2023, 05:31:31 PM »
Ok..  Well I got it to work, but it's not IDEAL.

This is because (and sorry for not really clarifying this), I wanted to use the SHIFT+W combination while then sending the key command.

Apparently VoiceAttack will take a trigger of something like SHIFT+W and then not execute and send another key while SHIFT+W is being pressed...

I wonder if there's some creative way to get that to work?  Some limitation in the system what VoiceAttack can't solve?  Or something creative that VoiceAttack COULD implement in the future to allow for a keystroke to still be executed while a SHIFT+W combination is beind held.?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Send Keypress When Pressing (and Holding) Another Key
« Reply #5 on: March 02, 2023, 05:46:25 PM »
Apparently VoiceAttack will take a trigger of something like SHIFT+W and then not execute and send another key while SHIFT+W is being pressed...
Can you clarify what you mean by this?


Unless the "Shortcut is invoked only when all keys are released" option is enabled, VoiceAttack will trigger a command whenever the key(s) assigned to the "When I press keys" option are pressed, regardless of other keys being pressed.
E.G. if you assign a command to "W", that will also trigger when Shift-W is pressed, as well as when somthing like Ctrl-Alt-Shift-W is pressed, etc...
Likewise, a command assigned to Shift-W will also trigger when something like Ctrl-Alt-Shift-W is pressed

The order of the keys does not matter either; if you have a command assigned to Shift-W, pressing the W key first, and the Shift key second, will still trigger the command.


In all of these scenarios, the command should trigger and execute, but you seem to be saying it does not execute?

Starblue7

  • Full Member
  • ***
  • Posts: 131
Re: Send Keypress When Pressing (and Holding) Another Key
« Reply #6 on: March 02, 2023, 05:57:01 PM »
With needing to hold down the below trigger key(s).
What I'm saying is, that when I choose:

Then I Press Keys:  SHIFT+W    (Will work if only W is assigned here)

When this command executes, do the following sequence:
Press NumPad Multiply key and hold for .0005 seconds and release

The above will not work when I press and hold SHIFT+W

It WILL work if I press and hold JUST the W key (when I change to 'When I Press Keys: W')

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Send Keypress When Pressing (and Holding) Another Key
« Reply #7 on: March 02, 2023, 06:02:30 PM »
Do you have any of the options on the "Command Shortcut" dialog (opened by clicking the currently-assigned keyboard shortcut) enabled (checked) at this point?

Starblue7

  • Full Member
  • ***
  • Posts: 131
Re: Send Keypress When Pressing (and Holding) Another Key
« Reply #8 on: March 02, 2023, 06:07:38 PM »
No.  Nothing is selected in the Command Shortcut window.

Just the assigned Keys  Left Shift + W

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Send Keypress When Pressing (and Holding) Another Key
« Reply #9 on: March 02, 2023, 06:10:19 PM »
Then the command should logically trigger when you press that key combination.

Try restarting your computer (using the "Restart" option in the Windows Start menu, not be shutting down and powering back on), just in case

Starblue7

  • Full Member
  • ***
  • Posts: 131
Re: Send Keypress When Pressing (and Holding) Another Key
« Reply #10 on: March 02, 2023, 06:53:39 PM »
Ok.  well restarted. 

So yeah, in Notepad, when I direct the command to be placed there, I can do the SHIFT + W, hold it down and get this result:
W*WWWWWWWWWWWWWWWWWWWWWW  (so it's doing the * and continuing the sending of W)

But when I switch to the game, it won't do it.  It'll only kick it off if I wildly spam on and off the SHIFT + W keypress
It behaves like that SHIFT KEY is blocking the ability for the next key (numpad *) being sent or recognized.

So if I choose just the W key, then things work ok in the game and the numpad * is passed normally.
When I do SHIFT+W instead, it won't work.

Additional information, this is a TrackIR reentering key bind command (numpad *)
I did try to EXPLICITELY send the resulting numpad * to the TrackIR application also running, but that made no difference.  As it stands now, with just the W key being used, there is no specification to send the numpad * key to the game nor active window.  The 'Send Command to this target' is unchecked and it works with just W.
But again, when I try to do SHIFT+W, then it doesn't behave.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Send Keypress When Pressing (and Holding) Another Key
« Reply #11 on: March 02, 2023, 06:58:34 PM »
Does the command still trigger and is it the keypress that doesn't appear to be getting through, or is the command not triggered at all?

Are you attempting to use this in DCS?

Starblue7

  • Full Member
  • ***
  • Posts: 131
Re: Send Keypress When Pressing (and Holding) Another Key
« Reply #12 on: March 02, 2023, 07:03:56 PM »
The command SHIFT+W still triggers.
That is to say that when I press SHIFT+W it will do what is proper within the game.
It's just the resulting numpad * keypress that doesn't appear to be getting through.

No, it's not DCS.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Send Keypress When Pressing (and Holding) Another Key
« Reply #13 on: March 02, 2023, 07:09:43 PM »
If you press the same combination of keys (Shift, W, then numpad multiply) physically, while keyboard shortcuts are disabled in VoiceAttack, does that work?

You're holding down the Shift key, which means you're not sending Shift-W and numpad multiply, but instead Shift-W and Shift-numpad multiply (I.E. the modifier will apply to any keys being pressed; this is not specific to VoiceAttack)

Starblue7

  • Full Member
  • ***
  • Posts: 131
Re: Send Keypress When Pressing (and Holding) Another Key
« Reply #14 on: March 02, 2023, 07:35:30 PM »
Yeah.  you're right.  I should have thought that through more...

I suppose I'd still hope for some keystroke to be kicked off via VoiceAttack without having to inherit the initial control(SHIFT) key press in order for it to take effect (on occasion where the combination SHIFT+W) are being held down.

Thanks for the help.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Send Keypress When Pressing (and Holding) Another Key
« Reply #15 on: March 02, 2023, 07:39:25 PM »
Are you using the Shift key specifically to trigger the command, or does that need to be held down ingame as well?

If it's only the former, you could try using a keypress action for the Shift key set to "Release Key(s)", before sending the numpad multiply keypress (possibly with a short pause in-between)

Starblue7

  • Full Member
  • ***
  • Posts: 131
Re: Send Keypress When Pressing (and Holding) Another Key
« Reply #16 on: March 02, 2023, 07:48:18 PM »
Needs to be held in game as well.

Or an option in VoiceAttack to ignore modifier Combo keys (like ALT, CTRL, SHIFT).  Those keys would be ignore for the instant when the resulting keypress command is sent.