Run another application using AppleScript without

2019-05-24 10:55发布

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 possible to prevent the other application from showing in the dock, yet show its GUI as it would normally do when executed?

Thanks

2条回答
疯言疯语
2楼-- · 2019-05-24 11:27

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.

查看更多
Lonely孤独者°
3楼-- · 2019-05-24 11:34

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:

  1. Right- or Ctrl-click the other app and Choose 'Show Package Contents'
  2. Open the 'Contents' folder
  3. Open the Info.plist in your text/xml editor of choice*
  4. Add these two lines right after the first line that says <dict>
    <key>NSUIElement</key>
    <true/>
  5. 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.

  1. Add a Child to the root ("Information Property List").
  2. Set the name to NSUIElement.
  3. From the Edit (or context) menu, set the Value Type to Boolean.
  4. Click the checkbox ON (sets the bool to true).
查看更多
登录 后发表回答