How to run another instance of an Application by double clicking on its Icon

ankitverma05

Registered
How can i run another instance of the application while the application is already running, by clicking on the application Icon in /Applications/.
I dont want to run it from /Applications/myapp.app/Contents/MacOS/myapp

Can i link a script file containing statements
(1)open -n /Applications/myapp.app
or
(2)open -n /Applications/myapp.app/Contents/MacOS/myapp

with the application icon click....

i have tried making changes in Info.plist of the application
key-Executable file value-myapp {present at /Applications/myapp.app/Contents/MacOS/myapp}

changes
key-Executable file value-launch.sh {present at /Applications/myapp.app/Contents/MacOS/launch.sh}

As i know an Application Bundle on OS X can only be started once.by simply copying the bundle the same application can be launched twice.

Is there any solution for the above problem

Thanks
Ankit
ankitverma05@gmail.com
 
I did have an AppleScript somewhere for opening the same application in different languages on the same time. (Practical for exactly what I needed it at the time, to be able to compare it in different localizations)
But I can't remember where the script is now, whether it's in some old hard drive or if I've deleted it years ago.
So if that could be done with AppleScript when Mac OS X was in 10.3 or 10.4, it should still be possible.
 
Thanks for making me believe that it is possible.
How can i link the apple script with the application Icon(Info.plist)
I could move the original application to somewhere other than /Applications, replace it with your new script
I can create such an app with osacompile -e 'do shell script "open -n /Path/To/Application.app"' -o /Path/To/New/Script.app

The Requirement is like i want to run another instance by double clicking on the same application Icon present at /Applications/
 
Giaguara identified a specific need to run more than one instance of an app.
Some apps do not allow more than one instance at a time.

Your requirement to add more than one running instance, simply by double-clicking the same app icon, seems very unlikely to ever work in OS X.
Maybe there's other methods to do what you want...
Can you give more details about the app, and what it does?
Also, what is the pressing need where you have to run more than one instance in OS X?

Is your "myapp.app" one that you created?
 
Giaguara identified a specific need to run more than one instance of an app.
Some apps do not allow more than one instance at a time.

Your requirement to add more than one running instance, simply by double-clicking the same app icon, seems very unlikely to ever work in OS X.
Maybe there's other methods to do what you want...
Can you give more details about the app, and what it does?
Also, what is the pressing need where you have to run more than one instance in OS X?

Is your "myapp.app" one that you created?







Yes "myapp.app" is created by me
if we run the unix executable(myapp) file present at /Applications/myapp.app/Contents/Macos/myapp it runs another instance.
In this case when second instance run it passes message to first instance(through IPC) and kills the second instance.
the same i want to run another instance if i double click the application icon ..
 
So, your second instance either cancels (quits) the first, or the running first instance won't allow more instances.
Only one instance at a time - as I would expect, and that's completely normal.

As I understand it, if you need to use more than one instance of an app, the app needs to be coded to allow that.
Is your app coded to allow more than one instance (apparently not?)

OS X does not generally expect that applications will be running in more than one instance, although multiple windows can often serve a similar function to multiple instances, without the additional overhead of applications running in multiple memory spaces

With that in mind - I think you misunderstood my question, so I'll try phrasing it differently:
Can you open more than one window in your app, which might achieve the same results?

If your answer is something like "That doesn't help me" (but did you try it out?), then you should post your question in an Xcode or developers question thread.
 
So, your second instance either cancels (quits) the first, or the running first instance won't allow more instances.
Only one instance at a time - as I would expect, and that's completely normal.

As I understand it, if you need to use more than one instance of an app, the app needs to be coded to allow that.
Is your app coded to allow more than one instance (apparently not?)

OS X does not generally expect that applications will be running in more than one instance, although multiple windows can often serve a similar function to multiple instances, without the additional overhead of applications running in multiple memory spaces

With that in mind - I think you misunderstood my question, so I'll try phrasing it differently:
Can you open more than one window in your app, which might achieve the same results?

If your answer is something like "That doesn't help me" (but did you try it out?), then you should post your question in an Xcode or developers question thread.




The Second instance checks whether there is one instance running { if true it quits itself else this is the first instance }
Only one instance at a time seems to be the normal behaviour
Double clicking on the application icon will/should run 1 instance while again double clicking on the same applcaition icon should run another instance
No i cannot open more than one window by double clicking on the same application icon .
I have posted the same Query on Apple Support Communities https://discussions.apple.com/message/19887490#19887490
Sorry for troubling you
 
I didn't ask if you could open more than one window by double clicking on the app's icon.
I DID ask "Can you open more than one window in your app?" - such as in Safari (File menu/New Window). Each time you select that item in Safari, it adds another browser window. I recognize that this is simply adding more windows to your opened app, and is not another instance. But, can you say that will NOT give you the flexibility that you are trying to find?

So, here's the question, phrased differently:
Does adding another window to your app give you the result that you are asking for, without needing another instance?

If NOT, you may also want to post at the Apple developer support area. Someone there may have some suggestions how to change your app to allow launching multiple instances.

Multiple instances of one app is unusual in OS X, and your app does need to be coded to support that. It's not the default behavior, even if you make copies of the executable app. Your app still needs to allow multiple instances, and, apparently, your app does not support that.

I have never heard of ANY OS X app that would start another instance by double-clicking the same icon, and I think it's doubtful that you will get that to work, at least in the OS X GUI.

Just curious - what does your app do?
 
I didn't ask if you could open more than one window by double clicking on the app's icon.
I DID ask "Can you open more than one window in your app?" - such as in Safari (File menu/New Window). Each time you select that item in Safari, it adds another browser window. I recognize that this is simply adding more windows to your opened app, and is not another instance. But, can you say that will NOT give you the flexibility that you are trying to find?

So, here's the question, phrased differently:
Does adding another window to your app give you the result that you are asking for, without needing another instance?

If NOT, you may also want to post at the Apple developer support area. Someone there may have some suggestions how to change your app to allow launching multiple instances.

Multiple instances of one app is unusual in OS X, and your app does need to be coded to support that. It's not the default behavior, even if you make copies of the executable app. Your app still needs to allow multiple instances, and, apparently, your app does not support that.

I have never heard of ANY OS X app that would start another instance by double-clicking the same icon, and I think it's doubtful that you will get that to work, at least in the OS X GUI.

Just curious - what does your app do?


what you are saying is absolutely right
In my case if my application is running and application window is not opened(visible in system tray) ,For opening its window i have to click the appicon in system tray .From the scroll down options i open the application window
 
A "system tray" doesn't exist in OS X. I'm guessing you mean the Dock?

Does your application allow opening another window?

What is your app's purpose - what does it do?

Generally, OS X apps do not close when the app's window is closed (as in Windows), although there are some exceptions to that.

As you learn more about OS X, you will certainly discover other ways that OS X is different from Windows.
Apple has a good support area, that's dedicated to those distinctions (not always dramatically different): http://support.apple.com/kb/HT2514
Also, here: http://support.apple.com/kb/HT2512
 
I do not know why you need two or more instances running. How about duplicating the app with a new name. Then they both can be running at the same time.
 
Might work, if the app is coded to allow it.
The OP is not yet sharing why he wants more than one instance.
And, the OP wants to be able to click the same app icon again, to launch more than one instance. That won't happen with two separate apps, either.
 
Some apps do not allow multiple copies of the app to open simultaneously. Firefox comes readily to mind. Not even different versions of the browser may operate simultaneously.
 
Back
Top