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...
// 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
// 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:
// 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.