Author Topic: Command-line Exit Routine  (Read 234 times)

chinagreenelvis

  • Newbie
  • *
  • Posts: 3
Command-line Exit Routine
« on: July 11, 2017, 09:01:11 am »
A simple option such as -exit, if it doesn't exist already (and if it does I haven't been able to find it), would be helpful for automation of the program.

I currently use AutoHotKey to launch VoiceAttack with certain programs, and although AHK has its own command for shutting down a program, this can cause problems with Windows system tray icons hanging in limbo. An exit parameter would be ideal.

Thanks!

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 1225
Re: Command-line Exit Routine
« Reply #1 on: July 11, 2017, 09:16:53 am »
Are you wanting an exit code or are you just wanting to be able to kill any open instance of VA?

chinagreenelvis

  • Newbie
  • *
  • Posts: 3
Re: Command-line Exit Routine
« Reply #2 on: July 11, 2017, 05:00:16 pm »
I personally only run one instance, but I suppose an exit option for specific instances would be helpful for anyone who runs more than one.

-exit (most recent instance)
-exit [instance id] (for a specific instance)
-exit all (for all instances)

Gary

  • Administrator
  • Hero Member
  • *****
  • Posts: 1225
Re: Command-line Exit Routine
« Reply #3 on: July 11, 2017, 05:32:58 pm »
Ok.  So, maybe I'm misunderstanding.  Would the -exit param be so that it executes OTHER parameters first and then causes VA to exit, or does it just kill VA straight away?

To kill VA straight away with a parameter is trivial.  You can even do it yourself by executing a command externally which contains an inline function:

using System;

public class VAInline
{
   public void main()
   {
           Environment.Exit(0);
   }
}


Exiting VA *after* everything is completed would not be trivial.  Since everything runs in an asynchronous manner, there would need to be a framework established to watch for everything to be complete and then exit when safe. 
Hope that helps some!
« Last Edit: July 11, 2017, 05:42:49 pm by Gary »

chinagreenelvis

  • Newbie
  • *
  • Posts: 3
Re: Command-line Exit Routine
« Reply #4 on: July 12, 2017, 01:21:47 pm »
Unfortunately, I'm not coding in C, but simple batch and AHK. Most people using automation will be doing the same, which is why a command-line-based exit option would be needed.

Few programs, if any, use an exit parameter as a complete-after-other-options trigger. Generally it's used to exit an already running program, just via the command line.

For exiting the program after other operations have bee completed, I would think a macro-based exit routine would be used inside the program itself. (This would be equally helpful, since a hotkey could be assigned for exiting the program.)

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1013
  • RTFM
Re: Command-line Exit Routine
« Reply #5 on: July 12, 2017, 02:22:48 pm »
To kill VA straight away with a parameter is trivial.  You can even do it yourself by executing a command externally which contains an inline function
I have to point out here that shutting down VoiceAttack in such a manner will trigger the "VoiceAttack Improper Shutdown" message at startup with most implementations; I have tried:

Code: [Select]
Environment.Exit(0);As a C# inline function; Displays the message.

Code: [Select]
Close 'VoiceAttack' process
As a VoiceAttack action inside a command; Displays the message.

Code: [Select]
Application.Exit();As a C# inline function; This actually causes VoiceAttack to freeze after "Unloading plugins", though it doesn't display the warning afterwards despite having to kill it.

Code: [Select]
Application.OpenForms["frmMain"].Close();As a C# inline function; Does not display the message.

Code: [Select]
Close window 'VoiceAttack'As a VoiceAttack action inside a command; Does not display the message.
However, the latter two are reliant on the "Minimize to system tray" option being disabled, presumably as otherwise the window/form handle won't exist.


I've thought about requesting an "Exit" action built-in to VoiceAttack, which would gracefully shut it down without triggering the warning, but deemed it too niche.