Run another application using AppleScript without showing it on the dock

时光怂恿深爱的人放手 提交于 2019-12-08 02:20:47

问题


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


回答1:


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).



回答2:


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.



来源:https://stackoverflow.com/questions/4284256/run-another-application-using-applescript-without-showing-it-on-the-dock

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!