Passing command line arguments to a running instance


#1

i have a singleton instance juce app (moreThanOneInstanceAllowed() returns false). I can successfully drop a file on the icon and anotherInstanceStarted() is invoked. However, what I want to do is be able talk to the running app from the command line, by seemingly invoking another instance.

For example I want to do things like this:

myApp.exe
myApp.exe -setParameter foobar 123
myApp.exe -setParameter baz 456

Is that possible? It doesn’t seem like HandleCommandLine() gets invoked when I do that.


#2

You can do that if you make moreThanOneInstanceAllowed() return true, and then manually use your own InterprocessLock and message broadcasting to communicate between the two instances.


#3

Is there a way to send multiple command lines to a single running app, without launching a separate instance each time?


#4

You can call MessageManager::broadcastMessage as often as you like!


#5

When another instance is started it comes to the anotherInstanceStarted() started of the previous instance. So we can use the command line argument to do some processing in the first instance. This one way u can communicate to the juce application from outside