Pass the selected file to the running program IF it is already running

I have created a button by dropping a program file to a toolbar in customization mode which opens the following dialog:

This causes the program to start and pass the selected file to it. So far, so good.

Unfortunately, among the various options there is no option which says: If the program is already running then do not start a second instance of the program but only pass the selected file to the already running program.

How can I achieve this?

image

How you do that will depend on the program. Many programs which can do that will do it automatically. Maybe this one can't do it, or maybe it requires an extra argument on the command line.

You would need to ask the program's authors (or help forum, etc.) how to run their program in a way that sends files to an existing instance instead of opening a new one. If you find that out and are still stuck, we can then tell you how to turn that into an Opus button.

Sending the command line parameter to the window handle? This IMO would have the same effect as drag&drop?

You can't send command lines to window handles.

You'll need to ask the program's authors/support how the program works, or find the details in the program's manual if they are in there.