Interaction with nircmd / autohotkey or similar

Ok, I'll give an example of what I would like to achieve.

nircmd makes use of script.ncl files, which are just multi line text files with extension ncl.

Lets say I have a script which starts vmware services:

(a script.ncl file simply containing the following on three lines)

service auto "VMwareHostd"
service auto "VMUSBArbService"
service auto "VMAuthdService"
service start "VMwareHostd"

At the moment If I wanted to use the dopus command editor box, I could ONLY input something like this:

@admin
nircmd.exe service auto "VMwareHostd"
nircmd.exe service auto "VMUSBArbService"
nircmd.exe service auto "VMAuthdService"
nircmd.exe service start "VMwareHostd"

However nircmd.exe is called up 4 times, which is not the correct way to be used. The above works fine in this case, but If I want to use it for say sending keystrokes, unfortunately the behaviour is jittery/unreliable/not executed at all.

It would make things much easier for me if I dispense the need to use 'proprietry' ncl files, and just 'hardcode' the commands into dopus itself + edit whenever, rather than create and store many separate ahk / ncl etc. files. I already know you can embed vbscripts.

So in other words, I would like nircmd to think that dopus passed a ncl file with this text.
ie. a method to create such 'scripts' on the fly, similar to the way ms-dos batch files are created (eg. 'script.ncl' could be generated in a temp folder, and its path passed to the program).

Is there a simple way to achieve this? Am I correct to think you could create a universal dopus user command template that can be adjusted depending on the type of extension wanted? But unfortunately this is beyond me. Any help in the right direction greatly appreciated.

...that statement is the crux of your challenge. Opus can't change what a program "thinks" it's being sent... you're stuck having to satisfy the requirements of the program (nircmd). If the main part of what you're trying to achieve is to simply store all this info directly in Opus instead of separate text files, then that's easy enough to do though. An example:

[code]@runmode:hide
@set file={alias|temp}\temp_{time|hhmmss}.ncl

echo service auto "VMwareHostd">{$file}
echo service auto "VMUSBArbService">>{$file}
echo service auto "VMAuthdService">>{$file}
echo service start "VMwareHostd">>{$file}

notepad {$file}[/code]
...if you put this in an Opus button, and set the button to Function: MS-DOS Batch Function it should open a text file in notepad with all of your commands. To get nircmd to launch it, just swap out the call to "notepad" on the last line for the full path to wherever you've got nircmd.exe stashed on your system.

What the button code is doing:

  • Uses the @runmode:hide command modifier to suppress the DOS window that would otherwise popup from setting the button function type to MS-DOS Batch Function
  • Uses the @set command modifier to set an internal Opus variable (that we'll call file) that resolves to the path to your user profile temp folder with an additional filename based on the time. Using the time will result in you accumulating a bunch of these temp files in your temp folder though, so if you don't periodically empty your temp folder - consider using a static name (nircmd.ncl or something)
  • Uses the DOS echo command to write the text you want into the file (referenced using the variable defined in the step above)
  • Launches whatever external program you want - passing the path to the temp file to it

...hopefully that helps in some way?

:thumbsup: Yes, thank you, that certainly helps a great deal. Slowly I am learning bit by bit. I shall be exploring this..

Of course ms-dos can output to text, I knew there would be a way!

indeed, thanks again