使用 AppleScript 运行另一个应用程序而不将其显示在 Dock 上

发布于 2024-10-04 12:18:42 字数 156 浏览 0 评论 0原文

使用 AppleScript,您可以创建运行另一个应用程序的脚本,然后将该脚本本身另存为应用程序并将其放置在 Dock 中。问题(不是真正的问题)是,当您单击它时,它仍然会在扩展坞上显示其他应用程序。是否可以阻止其他应用程序在扩展坞中显示,但仍像执行时通常那样显示其 GUI?

谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

疯到世界奔溃 2024-10-11 12:18:42

我能想到的唯一解决方案是实际修改“其他应用程序”以使其没有 Dock 图标。它有效,但很糟糕:
•是的,您直接修改其他应用程序,而不是通过脚本执行某些操作。
•因此,它将改变所述其他应用程序的每次启动,而不仅仅是从您的脚本中进行调用。
•它阻止其他应用程序拥有菜单栏(尽管按键组合和任何窗口内控件仍然有效)。

不过,它很容易逆转,并且几乎总是可以通过添加 GUI 模式来完成标记到应用程序的 Info.plist 文件:

  1. 右键或按住 Ctrl 键单击其他应用程序,然后选择“显示包内容”
  2. 打开“内容”文件夹
  3. 在您选择的文本/xml 编辑器中打开 Info.plist*
  4. 将这两行添加到右侧在第一行
    之后
    NSUIElement
  5. 保存,然后启动应用程序。请记住...没有菜单栏,因此请确保其中一个窗口具有焦点,并在验证它在没有 Dock 图标的情况下运行时按 -Q 退出。

*如果您对编辑 xml 感到厌烦,或者 plist 文件是二进制文件,则您将需要一个专用的 plist 编辑器。 Apple 自己的属性列表编辑器包含在其免费的开发工具中。

  1. 将子级添加到根(“信息属性列表”)。
  2. 将名称设置为 NSUIElement
  3. 从编辑(或上下文)菜单中,将值类型设置为布尔值。
  4. 单击复选框 ON(将布尔值设置为 true)。

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).
土豪我们做朋友吧 2024-10-11 12:18:42

构建之前的答案——您可以使用相同的 XML 代码修改 Applescript 应用程序的 Info.plist。这将阻止 Applescript 应用程序显示图标(并且有一个菜单栏,根据我的经验,对于这种类型的“应用程序”而言,菜单栏无论如何都无法使用),但是您的主应用程序(您从 applescript 启动的应用程序)将像往常一样显示在 Dock 中。

我在 OSX 10.7 Lion 上尝试过,它成功了。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文