Author Topic: Long press key without performing the short press action  (Read 2015 times)

paul

  • Newbie
  • *
  • Posts: 16
Long press key without performing the short press action
« on: July 31, 2020, 09:36:05 AM »
Hi,

I'm disabled and use several buttons and straws which are mapped through keys using Voice Attack(best $10 I've ever spent).

One of the buttons I use toggles crouch, so one click crouch, next click stand.
Same button via double click adds armor(warzone).

I'm trying to add another function using a 'long press', while holding down the input button i want to have the fire(LMB) loop to fire really quickly.

I have the following loop which works except when I push the button it crouches first before it starts firing. Is there a way I can stop this happening?

Thanks for any help
Paul


Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Long press key without performing the short press action
« Reply #1 on: July 31, 2020, 02:18:00 PM »
The simplest way to get around this may be to check both the "Shortcut is invoked when long-pressed" and "Invoke also on short/standard press (Advanced)" options in your crouch command (which I'm assuming is a separate command that currently doesn't have either option checked), and adding this at the top of that command:
Code: [Select]
Begin Text Compare : [{CMDLONGPRESSINVOKED}] Equals '1'
End Condition - Exit when condition met

That will exit the command if it's invoked by a long press, while still having it work when using a short press.


You could also merge the crouch and "fast fire" commands into one, using the same principle, E.G.
Code: [Select]
Begin Text Compare : [{CMDLONGPRESSINVOKED}] Equals '1'
    Start Loop While :  Keyboard Key '2 "' Is Pressed
        Click left mouse button
    End Loop
Else
    Press C key and hold for 0,01 seconds and release
End Condition

paul

  • Newbie
  • *
  • Posts: 16
Re: Long press key without performing the short press action
« Reply #2 on: July 31, 2020, 04:56:31 PM »
The simplest way to get around this may be to check both the "Shortcut is invoked when long-pressed" and "Invoke also on short/standard press (Advanced)" options in your crouch command (which I'm assuming is a separate command that currently doesn't have either option checked), and adding this at the top of that command:
Code: [Select]
Begin Text Compare : [{CMDLONGPRESSINVOKED}] Equals '1'
End Condition - Exit when condition met

That will exit the command if it's invoked by a long press, while still having it work when using a short press.


You could also merge the crouch and "fast fire" commands into one, using the same principle, E.G.
Code: [Select]
Begin Text Compare : [{CMDLONGPRESSINVOKED}] Equals '1'
    Start Loop While :  Keyboard Key '2 "' Is Pressed
        Click left mouse button
    End Loop
Else
    Press C key and hold for 0,01 seconds and release
End Condition

Thanks so much for taking the time to reply to me.

How would I implement the second solution you mentioned?

Would i create a new command i.e 'fast fire' and just paste that code in?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Long press key without performing the short press action
« Reply #3 on: July 31, 2020, 05:05:06 PM »
Either create a new command and uncheck the "When I press keys" option for your existing short and long press commands (or delete them), or modify one of them (disabling/deleting the other).

Commands cannot be created from action list text, they need to be recreated manually. I've exported and attached this specific command so you can import it into your profile, however.
Do double-check the assigned keys and the delay on the keypress.

paul

  • Newbie
  • *
  • Posts: 16
Re: Long press key without performing the short press action
« Reply #4 on: August 01, 2020, 06:33:55 AM »
wow, thanks so much for making that for me  :o
I'll test it out later today and report back

paul

  • Newbie
  • *
  • Posts: 16
Re: Long press key without performing the short press action
« Reply #5 on: August 02, 2020, 01:02:03 PM »

The command you made worked perfectly but it got a bit confusing having two separate fire buttons for different guns.

I tried making a loop so that when the left mouse button is held down it repeatedly clicks;

    Start Loop While :  Left Mouse Button Is Pressed
        Click left mouse button
    End Loop

But when I clicked apply I couldn't even close va! haha

Is there a better way to do it?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Long press key without performing the short press action
« Reply #6 on: August 02, 2020, 05:02:11 PM »
There is currently no method for distinguishing physical input from VoiceAttack input, I.E. "Left Mouse Button Is Pressed" is true when VoiceAttack is pressing that button, so it's a self-sustaining loop; There is no real way around that.