Author Topic: Ending current command by pressing any key  (Read 3292 times)

Greyswandir

  • Newbie
  • *
  • Posts: 2
Ending current command by pressing any key
« on: April 11, 2021, 03:48:48 AM »
How to end currently running command by pressing any key?
Thank you!

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Ending current command by pressing any key
« Reply #1 on: April 11, 2021, 03:52:54 AM »
If you're looking to stop any and all running commands, that can be done using the "Stop All Commands Hotkey" option on the "Hotkeys" tab of the VoiceAttack options window


To stop a specific command, while leaving other commands running, you could create another command set up to trigger off a keypress, containing a "Stop Another Command" action

Greyswandir

  • Newbie
  • *
  • Posts: 2
Re: Ending current command by pressing any key
« Reply #2 on: April 11, 2021, 04:41:43 AM »
If you're looking to stop any and all running commands, that can be done using the "Stop All Commands Hotkey" option on the "Hotkeys" tab of the VoiceAttack options window


To stop a specific command, while leaving other commands running, you could create another command set up to trigger off a keypress, containing a "Stop Another Command" action

In my case, I run only one command, so stop all or stop specific is both working solutions, point is that it stops on-any-key pressed, not specific hotkey.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4759
  • RTFM
Re: Ending current command by pressing any key
« Reply #3 on: April 11, 2021, 04:56:38 AM »
Ah. In that case it depends on whether the command you're looking to stop presses any keys using keypress actions.

If not, you could run a separate command (started by the command you're looking to stop) that uses a loop set up via the "Device State" to run while no keys are pressed, and to stop the other command after the loop (so that the action triggers once the loop stops when a keypress is detected).

E.G.
Code: [Select]
Start Loop While :  No Keyboard Key Is Pressed
End Loop
Write [Blue] 'Keypress detected, command stopped' to log
Kill command, 'Name of the command to be stopped'

Assuming the command that would be stopped doesn't loop forever, you'd probably also want to add an action at the end of it that stops the command that's running the loop, so it doesn't keep waiting when the command that should be stopped has stopped by itself already.


If, on the other hand, the command you're looking to stop uses keypress actions, you'd need to rig up a system where the monitoring command checks whether the key that has been pressed was likely pressed by the other command (E.G. by setting a variable containing the key(s) pressed in the other command, then checking whether the pressed key was listed in the monitoring command)