Author Topic: Setting "Send commands to this target" from command line option ?  (Read 1252 times)

Todrac

  • Newbie
  • *
  • Posts: 2
Hello,
My question is summarized in the topic.
Thanks in advance.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Setting "Send commands to this target" from command line option ?
« Reply #1 on: April 03, 2023, 09:55:31 AM »
That is possible, though not directly.

The "Send commands to this target" option at the profile level (as well as the "Send command to this target:" option at the command level) accepts tokens, which can in turn retrieve the value of a variable.

So, what you can do is to use a command that takes a passed text value, and stores that in a profile-scoped variable.

E.G.
The "Send commands to this target" option could be set to
Code: [Select]
{TXT:>>CommandsTarget}
and you could have a command like
Set commands target
Code: [Select]
Set text [>>CommandsTarget] to '{TXT:~passedText1}'
Write [Blue] 'Commands target set to: "{TXT:~passedText1}"' to log

so you can then enter something like this from a command prompt:
Code: [Select]
.\VoiceAttack.exe -command "set commands target" -PassedText "\"*notepad\""
which should show
Code: [Select]
External command : 'Set commands target'
Commands target set to: "*notepad"
in the log on the main window.

Executing a command at that point, assuming a window with its title ending in "notepad" exists (and that the target isn't being overridden at the command level), should result in input getting sent to that window.


Something to note is that variables logically won't have a value assigned to them yet when the profile loads initially, so you'd have to always set it from the command line first.

If that is undesirable, you can assign a command to the "Execute a command each time this profile is loaded" option, with contents like
Code: [Select]
Begin Text Compare : [>>CommandsTarget] Has Not Been Set
    Set text [>>CommandsTarget] to 'My default target'
End Condition


As a persistent profile scope (the ">>" prefix) is being used, the commands target will remain set to whichever value you last assigned to it, as long as VoiceAttack is running.
If you'd prefer the target to be reset to default when the profile is reloaded, you could use the non-persistent profile scope (the ">" prefix).

Todrac

  • Newbie
  • *
  • Posts: 2
Re: Setting "Send commands to this target" from command line option ?
« Reply #2 on: April 03, 2023, 07:54:28 PM »
Incredible, you have the answer to everything!
Thanks