Run another application using AppleScript without showing it on the dock
Using AppleScript you can create a script that runs another application, and then save that script itself as an application and place it in the dock. The problem (not really a problem) is that when you click it, it will still show the other application on the dock. Is it possibl开发者_如何学Goe to prevent the other application from showing in the dock, yet show its GUI as it would normally do when executed?
Thanks
The only solution I can think of is to actually modify the 'other app' to have no Dock icon. It works, but it's nasty:
•Yep, you're directly modifying the other app—not doing something from your script.
•Accordingly, it will change every launch of said other app, not just invocation from your script.
•It prevents OtherApp from having a menubar (though key combos and any in-window controls will still work).
It's easily reversed though, and can almost always be done just by adding a GUI mode flag to the app's Info.plist file:
- Right- or Ctrl-click the other app and Choose 'Show Package Contents'
- Open the 'Contents' folder
- Open the Info.plist in your text/xml editor of choice*
- Add these two lines right after the first line that says
<dict>
<key>NSUIElement</key>
<true/>
- Save, then fire up the app. Remember… no menubar, so make sure one of its windows has focus and -Q to quit when you verify it runs with no Dock icon.
*If you're squeamish with editing xml, or if the plist file is the binary variety, you'll need a dedicated plist editor. Apple's own Property List Editor is included with their free Dev Tools.
- Add a Child to the root ("Information Property List").
- Set the name to
NSUIElement
. - From the Edit (or context) menu, set the Value Type to Boolean.
- Click the checkbox ON (sets the bool to true).
Building off the previous answer -- you can modify the Info.plist of your Applescript application with the same XML code. This will prevent the Applescript app from displaying an icon (and having a menubar, which in my experience is unusable anyway for this type of 'app'), but your main application -- the one you're launching from the applescript -- will display in the Dock as usual.
I tried this on OSX 10.7 Lion and it worked successfully.
精彩评论