Author Topic: Keypress Hold Across Commands?  (Read 1815 times)

Starblue7

  • Full Member
  • ***
  • Posts: 131
Keypress Hold Across Commands?
« on: March 16, 2023, 08:28:18 PM »
Does VoiceAttack have an option to allow keypresses to be held down across commands, even if the command that caused the keypress(hold) ends?

OR.  Must I always have a constant loop running from the originating command in order to continue to have that keypress held down?

I have a situation where I need a keypress held down constantly, but sometimes need to kick off another command at the same that, that MAY require that keypress to be released, and then repressed and held, all the while with the originating command for the original keypress still running.  (If it's a loop).

Any suggestions on how to handle this?

SemlerPDX

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 280
  • Upstanding Lunatic
    • My AVCS Homepage
Re: Keypress Hold Across Commands?
« Reply #1 on: March 17, 2023, 12:55:30 PM »
When a command sends a keypress (and not release), it is in Windows.  That key is now seen as held down across all of Windows, not merely within the confines of some command in VoiceAttack.  A command could literally be one line, 'hold down F" and be done.  The "F" key would then be held down until manually pressed and released, or a new action was sent (from any command) in VoiceAttack to release that specific key.  You don't need to use any tricks to keep the original command running in order to retain this key hold state.

The VoiceAttack Action "Stop Processing All Commands" has a feature to release any/all keys that are currently held down.

SemlerPDX

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 280
  • Upstanding Lunatic
    • My AVCS Homepage
Re: Keypress Hold Across Commands?
« Reply #2 on: March 17, 2023, 01:09:07 PM »
Just read your other thread - figured it might help to direct your attention to the 'Key State Token Parameter Values' section of the VoiceAttack manual, if you need to get into detecting the current state of a key using Tokens.  You also should know that there is no harm to sending a 'key release' action to a key which is not held down, but also to add at least a ~0.05 pause between sending key press actions to ensure that each individual key down or release action is registered in the OS.  50 milliseconds is quite fast, and a good minimum time between keys, but adjust as needed if you have issues.  Some computers have no issue going well lower, others could potentially require higher .... ymmv.

Starblue7

  • Full Member
  • ***
  • Posts: 131
Re: Keypress Hold Across Commands?
« Reply #3 on: March 17, 2023, 04:18:00 PM »
The reason I ask is:
I did a test to run a command to hold a keypress down.

When I press Keys: O
Press Down O Key

The result was in notepad, the 'O' key registered the trigger keypress to kick off the command, and then pressed the 'O' key one more time and then stopped:    OO

So, based off of that, the 'O' key wasn't pressed down(held down) constantly to register something like OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.....
continuously.

SO.........
It'd seem in order to achieve the above I'd have to have some loop that would continue to run from the command, like:
Code: [Select]
Start Loop While : [{STATE_KEYSTATE:O}] Equals '1'
    Press down O key
End Loop
Above is just crude, but if I press the O key the first time, the loop with kick off and constantly give me OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO....
If I press the O key again, there will be a 'release' action in there that will set the keystate to 0 which will break the loop.


I just wanted to:

#1:  Find a way to have it so that when a command did the 'Press down Key', that it would not release it and keep it held down, to produce the OOOOOOOOOOOOOOOOOOOOOOOOOO........   UNTIL the key was unpressed/released.  WITHOUT having to do a loop.

#2:  REALLY REALLY want to find a way to prevent the hijacking of a key that's constantly pressed via a VoiceAttack command, to ONLY apply to the game if the game's internal chat window isn't open.
I suppose (since the 'ENTER' key kicks this off) I'd have to have a pause placed in all my commands to detect if the 'ENTER' key is pressed in order to be able to type normally in that text window until I exit it.
Since ENTER is also a carriage return, that subsequent ENTER may not exit the chat within the game (as a mouse click in the game itself could be use to take focus from the chat window).
Any creative suggestions on how to handle the above.

It'd really be awesome somehow to continue to send commands to have actions run in the game while one is still typing something in the chat window within the game!


Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Keypress Hold Across Commands?
« Reply #4 on: March 17, 2023, 04:27:54 PM »
Virtual keypresses don't cause character repeats, so while you'd only see a single character from a given press in an application like Notepad, the key does remain in a pressed state.


It'd really be awesome somehow to continue to send commands to have actions run in the game while one is still typing something in the chat window within the game!
That is not something VoiceAttack or any external application can facilitate without the target application explicitly supporting it (either by design or through modification).