Author Topic: Simple Question. I need help please.  (Read 1648 times)

SteveXM

  • Newbie
  • *
  • Posts: 17
Simple Question. I need help please.
« on: December 15, 2018, 07:50:33 AM »
Ive spent way to long trying to get this to work. I'm throwing in the towel.

How do i get the First and Second phrase stored as text variables. An example of how i want ot use this is for a command that will look like this

[Open;Close] [Notepad;Wordart]

I would like to be able to store each so that i can open and close specific programs.
Thank you

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Simple Question. I need help please.
« Reply #1 on: December 15, 2018, 08:08:43 AM »
Easiest way to extract parts of a spoken command phrase is the "{CMDSEGMENT:}" token.

Because it is zero-indexed, "Open" and "Close" would be "{CMDSEGMENT:0}, while "Notepad" and "Wordart" would be "{CMDSEGMENT:1}".

You can either convert the token into a text variable, or use it directly in a "Text" compare:
Code: [Select]
Begin Text Compare : [{CMDSEGMENT:0}] Equals 'Open'
    Write [Blue] 'Open' to log
Else
    Write [Blue] 'Close' to log
End Condition


More information on the "{CMDSEGMENT:}" token can be found in VoiceAttackHelp.pdf(open it by pressing F1 while VoiceAttack has focus), on page 132.

SteveXM

  • Newbie
  • *
  • Posts: 17
Re: Simple Question. I need help please.
« Reply #2 on: December 16, 2018, 09:56:49 AM »
Thank you so much for the help. It's simply amazing the things you can do with this program.

Acecool

  • Newbie
  • *
  • Posts: 5
Re: Simple Question. I need help please.
« Reply #3 on: June 08, 2019, 04:18:43 AM »
What I do right now is group together words for open, and words for close... Or raise / lower, etc...


So my command would look like this: [ Open; Launch; Run; ] [ Close; Exit; Kill; Kill Task; ] [ Notepad; Wordart ]

Then, you just determine if something is not '' ( because if it is '', then that group wasn't used )... You can assume a default ( by using if ... else ... end ), or just use what I have below ( if .. else if ... end )...

Also, since you have multiple programs, you can either set them up twice, once in the open, once in the exit if statement. You can set them up once, and the open / exit in each program..

ie: if open then if notepad then ... end if wordart then ... end else if close then if notepad then ... end if wordart then ... end end.

or if notepad then if open then ... end if close then ... end end... If wordart then if open then ... end if close then ... end...

Code: [Select]
// Open
Begin Text Compare: [{CMDSEGMENT:0}] Does not equal ''
Begin Text Compare: [{CMDSEGMENT:1}] Equals 'notepad'
Run notepad.exe
End Condition

Begin Text Compare: [{CMDSEGMENT:1}] Equals 'wordart'
Run wordart.exe
End Condition

// Close
Else if Begin Text Compare: [{CMDSEGMENT:1}] Does not equal ''
Begin Text Compare: [{CMDSEGMENT:1}] Equals 'notepad'
Run taskkill /fi "imagename eq notepad.exe"
End Condition

Begin Text Compare: [{CMDSEGMENT:1}] Equals 'wordart'
Run taskkill /fi "imagename eq wordart.exe"
End Condition
End Condition

or
Code: [Select]
// Notepad
Begin Text Compare: [{CMDSEGMENT:1}] Equals 'notepad'
Begin Text Compare: [{CMDSEGMENT:0}] Does not equal ''
Run notepad.exe
Else if Begin Text Compare: [{CMDSEGMENT:1}] Does not equal ''
Run taskkill /fi "imagename eq notepad.exe"
End Condition
End Condition

// Wordart
Begin Text Compare: [{CMDSEGMENT:1}] Equals 'wordart'
Begin Text Compare: [{CMDSEGMENT:0}] Does not equal ''
Run wordart.exe
Else if Begin Text Compare: [{CMDSEGMENT:1}] Does not equal ''
Run taskkill /fi "imagename eq wordart.exe"
End Condition
End Condition

I like the second one because it is grouped by program. You could also separate it completely and do this:

Code: [Select]
// Setup vars
Set Text filename ''


// Notepad - This doesn't need to point anywhere other than notepad.exe because it is in system32...
Begin Text Compare: [{CMDSEGMENT:1}] Equals 'notepad'
Set Text filename 'notepad.exe'
End Condition

// Wordart - This may need some path.. You can use %Username% and other ENVVars to make it dynamic between computers / users..
Begin Text Compare: [{CMDSEGMENT:1}] Equals 'wordart'
Set Text filename 'wordart.exe'
End Condition

// Open / Close
Begin Text Compare: [{CMDSEGMENT:0}] Does not equal ''
Run {filename}
Else if Begin Text Compare: [{CMDSEGMENT:1}] Does not equal ''
Run taskkill /fi "imagename eq {filename}"
End Condition

which I like even more because each app has a single thing to set... the filename / path... Then, the open / close code is executed which either runs the file / path set previously... Or it closes it using a built in method...

Note: taskkill doesn't seem to work with the full path, only the exe name, pid, etc... so you may need a second variable if you need to assemble a path.

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Simple Question. I need help please.
« Reply #4 on: June 08, 2019, 02:54:52 PM »
Please note that using segments in this manner will generate many unnecessary phrase variations, leading to longer profile load times (if used often within the same profile).

E.G.
"Open Close Notepad"
or
"Launch Kill Task Wordart"



If you're using taskkill to target by image name, you could just use the "/im" switch, E.G. "taskkill /im notepad.exe".

However, VoiceAttack has the "Stop a Process by Name" action, which will have the same effect without launching an external application.