【问题标题】:AppleScript can not activate FinderAppleScript 无法激活 Finder
【发布时间】:2016-01-27 16:22:16
【问题描述】:

我在我的 OSX 应用程序中使用 AppleScript 来激活 Finder 并使用 smb URL 打开 smb 共享文件夹。

     set the clipboard to "smb://192.168.99.99"
         tell application "Finder"
         activate
     end tell
     delay 0.5
     tell application "System Events"
         keystroke "k" using command down
     end tell
     delay 0.2
     tell application "System Events"
         keystroke "v" using command down
         keystroke return
     end tell

它运行良好,但在我的一位客户的 Mac 上无法运行。 Finder 未激活,但屏幕顶部的 Finder 菜单栏显示。

我尝试在他的 Mac 上使用脚本编辑器来执行相同的脚本,但 Finder 仍然没有激活。

到目前为止,这只发生在此客户的 Mac 上。他的 Mac 运行的是 10.10,升级到 10.11 但仍然不走运。

有人知道发生了什么吗?有什么方法可以“禁用”AppleScript?

【问题讨论】:

  • 在您的客户端的 Mac 上未启用 GUI 脚本,但您不需要使用 GUI 脚本来编写 Finder,因为它是本机可编写脚本的,如下面的答案所述。

标签: macos applescript finder


【解决方案1】:

您没有尝试模拟 Finder 键盘事件,是否有特定原因您不只是使用指令“打开位置”?

下面的脚本会打开我的 smb 共享卷:

set MyAddress to "smb://192.168.99.99"
open location MyAddress

当然,您的系统可能会询问您的登录名/密码是否尚未在您的钥匙串中设置。

【讨论】:

  • 谢谢,我是 applescript 的新手,不知道我能做到这一点。我将在客户端的 Mac 上尝试。但仍然想知道他的 Finder 发生了什么...
  • 我认为 Simon 的评论可能是正确的:在那台 Mac 上,您是否为您的脚本设置了可访问性?特别是如果那台 Mac 使用 El Capitain,Apple 会在该版本上重新实施安全性,默认设置是无访问权限。查看系统偏好设置/安全性/选项卡机密性。确保您的脚本在无障碍服务中被允许。
猜你喜欢
  • 2015-01-05
  • 2019-05-03
  • 1970-01-01
  • 1970-01-01
  • 2020-12-20
  • 2017-11-13
  • 1970-01-01
  • 2012-05-09
  • 2019-06-28
相关资源
最近更新 更多