# Help running Opus commands from AHK script

**URL:** https://resource.dopus.com/t/help-running-opus-commands-from-ahk-script/36867
**Category:** Help & Support
**Created:** [October 8, 2020, 2:55am UTC](https://resource.dopus.com/t/help-running-opus-commands-from-ahk-script/36867 "2020-10-08T02:55:49Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![H-Ce](https://resource.dopus.com/user_avatar/resource.dopus.com/h-ce/32/37878_2.png) [@H-Ce](https://resource.dopus.com/u/H-Ce)
#### Post date: [October 8, 2020, 2:55am UTC](https://resource.dopus.com/t/help-running-opus-commands-from-ahk-script/36867/1 "2020-10-08T02:55:49Z")

</div>

Tried to run this command

```auto
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:

```auto
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?

---

<div class="post-metadata">

### Author: ![lxp](https://resource.dopus.com/user_avatar/resource.dopus.com/lxp/32/33734_2.png) [@lxp](https://resource.dopus.com/u/lxp)
#### Post date: [October 8, 2020, 6:30am UTC](https://resource.dopus.com/t/help-running-opus-commands-from-ahk-script/36867/2 "2020-10-08T06:30:53Z")

</div>

Try `/acmd` instead of `/cmd`.

---

<div class="post-metadata">

### Author: ![Leo](https://resource.dopus.com/user_avatar/resource.dopus.com/leo/32/69732_2.png) [@Leo](https://resource.dopus.com/u/Leo)
#### Post date: [October 8, 2020, 8:26am UTC](https://resource.dopus.com/t/help-running-opus-commands-from-ahk-script/36867/3 "2020-10-08T08:26:23Z")

</div>

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

---

<div class="post-metadata">

### Author: ![H-Ce](https://resource.dopus.com/user_avatar/resource.dopus.com/h-ce/32/37878_2.png) [@H-Ce](https://resource.dopus.com/u/H-Ce)
#### Post date: [October 8, 2020, 12:40pm UTC](https://resource.dopus.com/t/help-running-opus-commands-from-ahk-script/36867/4 "2020-10-08T12:40:38Z")

</div>

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

(AHK script):

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

```

But again, this won't:

```auto
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?

---

<div class="post-metadata">

### Author: ![Leo](https://resource.dopus.com/user_avatar/resource.dopus.com/leo/32/69732_2.png) [@Leo](https://resource.dopus.com/u/Leo)
#### Post date: [October 8, 2020, 1:03pm UTC](https://resource.dopus.com/t/help-running-opus-commands-from-ahk-script/36867/5 "2020-10-08T13:03:07Z")

</div>

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

```nohighlight
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`.)

---

<div class="post-metadata">

### Author: ![DesertDwarf](https://resource.dopus.com/user_avatar/resource.dopus.com/desertdwarf/32/12717_2.png) [@DesertDwarf](https://resource.dopus.com/u/DesertDwarf)
#### Post date: [October 8, 2020, 8:50pm UTC](https://resource.dopus.com/t/help-running-opus-commands-from-ahk-script/36867/6 "2020-10-08T20:50:51Z")

</div>

> [@H-Ce](#):
>
> ```auto
> F1::
> Run, C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe /acmd Select DATE=newest SETFOCUS DESELECTNOMATCH
> return
> 
> ```

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.

---

<div class="post-metadata">

### Author: ![Leo](https://resource.dopus.com/user_avatar/resource.dopus.com/leo/32/69732_2.png) [@Leo](https://resource.dopus.com/u/Leo)
#### Post date: [October 8, 2020, 8:58pm UTC](https://resource.dopus.com/t/help-running-opus-commands-from-ahk-script/36867/7 "2020-10-08T20:58:33Z")

</div>

> [@DesertDwarf](#):
>
> You would probably want to try:
> 
> `Run, C:\Program Files\GPSoftware\Directory Opus\dopusrt.exe, , /acmd Select DATE=newest SETFOCUS DESELECTNOMATCH`

That is wrong based on the documentation here: [Run / RunWait - Syntax & Usage | AutoHotkey v1](https://www.autohotkey.com/docs/commands/Run.htm)

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](https://www.autohotkey.com/docs/commands/_EscapeChar.htm) 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.)
