Help running Opus commands from AHK script

Tried to run this command

Select DATE=both,newest SETFOCUS DESELECTNOMATCH

which works if placed in a button in DOpus.

But the following command, using dopusrt triggered via AHK doesn't seem to work:

F1::
    Run, C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe /cmd Select DATE=both,newest SETFOCUS DESELECTNOMATCH

There's no way to invoke that command from outside DOpus?

Try /acmd instead of /cmd.

You can set up hotkeys in Opus, FWIW. It may be easier when you can run things directly.

It's weird because this works (consider my problem solved)

(AHK script):

F1::
Run, C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe /acmd Select DATE=newest SETFOCUS DESELECTNOMATCH
return

But again, this won't:

F1::
Run, C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe /acmd Select DATE=both,newest SETFOCUS DESELECTNOMATCH
return

No biggie. But I don't see why the former would work and the latter would not, since the latter works like a charm as a button inside DOpus. To my understanding, dopusrt is nothing else but a tool for sending signals to DOpus to carry out its own internal commands – it doesn't affect or alter the command before reaching DOpus? If that's correct, then the latter example IS in fact the same as putting the command in a button?

Also /acmd and /cmd seems to make no difference in this particular case. I'm happy nonetheless, since I was able to accomplish what I wanted (to mark the newest file after recording system audio). Consider this question solved.

Although it's probably a minor quirk, this might be something to look into at some point?

It's probably not Opus causing that difference. Look at the AHK code you're running:

Run, <command line>

Looks like AHK is using the , character to separate arguments to its commands/functions. You're passing in an unquoted string as the command line for the Run command/function. It's going wrong when that command line includes a , character (DATE=both,newest). The problem probably lies there.

I don't know enough about AHK but I suspect you need to quote the arguments in some way.

(You should definitely also be quoting the dopusrt.exe path, since it contains spaces and will go haywire if something creates an exe or folder named C:\Programs.)

1 Like

I suspect you're missing commas. The command spec is:

Run, Target, WorkingDir, Options, OutputVarPID

(Every after the Target is optional.)

You would probably want to try:

Run, C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe, , /acmd Select DATE=newest SETFOCUS DESELECTNOMATCH

The , , in the middle is to leave an empty value for WorkingDir. Using the commas makes it abundantly clear to AHK what items are parameters and should mean you don't have to use quotes.

That is wrong based on the documentation here: Run / RunWait - Syntax & Usage | AutoHotkey v1

The same page also says what to do:

To pass parameters, add them immediately after the program or document name. If a parameter contains spaces, it is safest to enclose it in double quotes (even though it may work without them in some cases).

And:

If Target contains any commas, they must be escaped as shown three times in the following example: ...

(Since this is no longer about Opus, but how to use AHK, it'd be best to move to the AHK forum if you need more help.)