【问题标题】:Apple script not working on Mavericks with Microsoft outlookApple 脚本不适用于 Microsoft Outlook 的 Mavericks
【发布时间】:2014-09-20 07:16:45
【问题描述】:

我正在尝试在 Mavericks 上执行一个简单的 Apple 脚本,但它没有执行。我面临的错误是“预期的行尾,但找到了类名”

tell application "Microsoft Outlook"
    set currentTime to (the current date)
    set newEvent to make new calendar event with properties{subject:"New Appointment", start time:(currentTime + (60 *60)/2), end time:(currentTime + (60 * 60) +(60)/2)}
    open newEvent
end tell

我尝试通过运行命令删除重复的字典

/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -kill -r -domain local -domain system -domain user

重新启动 Mac ,重新安装 Outlook 并重新安装 Mavericks,但仍然是同样的问题。

谁能给我一些我完全不知道的新想法。

谢谢, 拉维。

【问题讨论】:

  • 你的脚本对我来说运行良好我正在运行 OSX 10.9.4 和 MSO 14.4.3 你能检查一下你的版本是否相同吗?
  • 感谢您的评论。是的,版本是相同的,它只发生在我的系统上。我有另一个具有相同 OS X 版本和 MSO 14.4.3 的系统,这个苹果脚本在那里工作得很好。
  • 两个系统有些不同,我不确定是什么。
  • 在我的工作 Mac 上,这是一个新构建的 Mavericks 映像,上面安装了 Office,然后将我的数据恢复到它,我发现预先存在的 Applescripts 包含语句“告诉应用程序” Microsoft Outlook"' 无法编译,可能无法链接到正确的字典。将语句更改为“告诉应用程序“Outlook””使其能够编译。该声明随后被改写为“告诉应用程序“Microsoft Outlook””。然后它再次无法编译。每次我重新打开脚本时,它都会再次失败。我第一次看到这里记录的这种行为:stackoverflow

标签: macos outlook applescript


【解决方案1】:

看起来你的脚本没有用行尾正确分隔。

tell application "Microsoft Outlook"
    set currentTime to (the current date)
    set newEvent to make new calendar event with properties {subject:"New Appointment", start time:(currentTime + (60 * 60) / 2), end time:(currentTime + (60 * 60) + (60) / 2)}
    open newEvent
end tell

应该是这样的。

【讨论】:

  • @mcgrailm 按照他之前写的方式,它只是一行代码。他收到的错误可能只是在他的构建上。看来现在已经不是这样了。不幸的是,我没有在这个 comp 上使用 Outlook 来测试它:/
  • @double_j :我尝试执行您提供的相同脚本,但结果相同的错误“预期行尾等,但找到了类名。”
  • @kishore 我可以在 Outlook 应用程序的 Comp 上进行尝试。没有返回错误,并且工作正常。这是您正在使用的脚本的唯一部分,还是还有更多?另外,您是否能够在 Applescript 运行之前构建它?在运行脚本之前尝试在 Applescript 中按命令“k”,以确保它会构建脚本并能够运行。
  • 我试过了,它没有编译并返回错误。我在其他几个系统上尝试了相同的脚本并在那里工作。我不确定为什么它不能在我的系统上运行。
  • @Kishore 那台计算机上安装了 Outlook 吗?
【解决方案2】:

只是一个格式说明......它应该看起来像这样:

set currentTime to (the current date)
set startTime to currentTime + (30 * minutes) -- + 30 minutes
set endTime to currentTime + (1 * hours) + 30 -- + 1 hour 30 seconds

tell application "Microsoft Outlook"
    set newEvent to make new calendar event with properties {subject:"New Appointment", start time:startTime, end time:endTime}
    open newEvent
end tell

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-18
    • 2016-02-24
    • 2020-07-04
    • 1970-01-01
    相关资源
    最近更新 更多