【问题标题】:Applescript: "Expected end of line, etc. but found class name."Applescript:“预计行尾等,但找到了类名。”
【发布时间】:2016-04-12 15:08:22
【问题描述】:

我一直在编写 AppleScript,但收到此错误: /Users/MYUSER/taskmaster/chromeCanary/lib/overrideOpenChrome.scpt:373:377: script error: Expected end of line, etc. but found class name.

奇怪的是,这个脚本似乎以前可以工作,所以我更加困惑,脚本如下:

 #!/usr/bin/osascript


 set ccss to "/Users/MYUSER/taskmaster/chromeCanary/chromeShouldStop/bool.rtf"
 set ccsr to "/Users/MYUSER/taskmaster/chromeCanary/chromeShouldRun/bool.rtf"

 do shell script "mv " & ccss & " " & ccsr 

 tell application "Google Chrome Canary"
   activate
 end tell
 display notification "30 Minutes remain" with title "TaskMaster" subtitle "Google Chrome Canary" with icon file "Users:MYUSER:taskmaster:assets:chrome-icon.icns"
 delay 900
 display notification "15 Minutes remain" with title "TaskMaster" subtitle "Google Chrome Canary" with icon file "Users:MYUSER:taskmaster:assets:chrome-icon.icns"
 delay 600
 display notification "5 Minutes remain" with title "TaskMaster" subtitle "Google Chrome Canary" with icon file "Users:MYUSER:taskmaster:assets:chrome-icon.icns"
 delay 60
 display notification "3 Minutes remain" with title "TaskMaster" subtitle "Google Chrome Canary" with icon file "Users:MYUSER:taskmaster:assets:chrome-icon.icns"
 delay 60
 display notification "1 Minute remain" with title "TaskMaster" subtitle "Google Chrome Canary" with icon file "Users:MYUSER:taskmaster:assets:chrome-icon.icns"
 tell application "Google Chrome Canary"
   quit
 end tell
 do shell script "mv " & ccsr & " " & ccss 

我的问题在哪里?路径是正确的,我检查并仔细检查了,所以不可能是这样。

编辑:我很愚蠢。如果您偶然发现此问题存在相同/相似的错误,请参阅下面的答案。

【问题讨论】:

  • 您的实际用户帐户文件夹是否包含空格?换句话说,我相信你已经用“MYUSER”代替了实际信息,实际信息看起来更像是“Whitman Colm”,有一个空格吗?
  • 另请注意,在某些 OSX 版本上,delay 命令听起来可能存在问题。请参阅 [此对话] (apple.stackexchange.com/q/161749/176513)。您可能想尝试将延迟更改为do shell script "sleep 900"

标签: macos applescript


【解决方案1】:

好的,显然你不能使用with icon file & display notification,你只能使用display dialog。你能得到的最接近的就是弄乱应用程序的图标。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多