【问题标题】:AppleScript: "Expected end of line, etc. but found identifier", Mavericks error?AppleScript:“预期行尾等,但找到标识符”,小牛队错误?
【发布时间】:2017-04-16 22:12:28
【问题描述】:

我有一个简短的脚本,我希望 Spotify 在 AppleScript 运行后在其中搜索特定歌曲,但我收到了这个错误,这似乎是只有小牛队在抱怨的事情(经过短暂的一轮谷歌搜索)。

tell application "Spotify" to activate
delay 0.1
tell application "Spotify" to keystroke "l" using command down

上面写着

语法错误:预期为行尾等,但找到了标识符

并指向“使用”。现在,我只写了很短的时间,但据我所知,这是很多人正在使用的确切语法,并且已经发布到 SO 和其他地方。

有什么想法吗?

干杯

【问题讨论】:

    标签: applescript


    【解决方案1】:

    命令keystroke 属于Processes Suite。您可以使用系统事件调用它。

    tell application "Spotify" to activate
    delay 0.1
    tell application "System Events" to tell process "Spotify"
        keystroke "l" using command down
    end tell
    

    【讨论】:

    • 那么你将如何用一个按键来做一个 if 语句呢?
    • 你的第二个答案更好......你不应该在告诉应用程序“Spotify”中嵌套告诉应用程序“系统事件”。
    • @adayzdone 谢谢你的提示,我编辑了答案。
    • @Erik 您可以在告诉应用程序“系统事件”块更多信息中进行 if 语句:if Statements
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多