【问题标题】:applescript to osascript conversion?applescript 到 osascript 的转换?
【发布时间】:2013-04-02 17:32:26
【问题描述】:

我正在使用 max msp 来运行 shell 命令,我一直在 applescript 中进行代码原型设计,并需要它们在 osascript 中运行 -

tell application "Google Chrome" to close tab 1 of window 1

转换为

osascript -e 'tell application \"Google Chrome\" to close tab 1 of window 1'

我已经转换了大约 10 个命令,但我被困在最后一个是

tell application "Google Chrome" to activate
tell application "System Events"
    tell process "Google Chrome"
        do shell script "/usr/local/bin/cliclick/ c:360,550"
    end tell
end tell

我认为是

osascript -e 'tell application \"Google Chrome\" to activate' -e 'tell application \"System Events\" to tell process \"Google Chrome\" to do shell script \"/usr/local/bin/cliclick c:360, 550\"'

cliclick 允许您通过 shell 使用鼠标。 http://www.bluem.net/en/mac/cliclick/。 c是点击的命令标识符,所以在x360 y550

我的语法正确吗?当我不包含 c 标识符时它可以工作。

谢谢

【问题讨论】:

    标签: applescript osascript


    【解决方案1】:

    我试过了,它给了我这个错误信息:

    99:151: execution error: System Events got an error: Invalid argument “360,” to command “c”: Expected two coordinates, separated by a comma. Example: “c:123,456” (1)
    

    解决方案:在数字 550 (c:360, 550) 之前有一个额外的空格,第二个值会丢失。删除空格字符,它应该可以工作(c:360,550)......

    这是我也更改了引用的版本:

    osascript -e "tell application \"Safari\" to activate" -e "tell application \"System Events\" to tell process \"Safari\" to do shell script \"/usr/local/bin/cliclick c:360,550\""
    

    【讨论】:

    • 感谢您的回答,它实际上使我了解了真正的问题,即 max msp 在逗号后面放置了一个空格。没想到这是个问题,但你证明了!反斜杠可以解决这个问题。我还需要原始报价,因为格式 osascript -e 'tell application \"Google Chrome\" to activate' -e 'tell application \"System Events\" to tell process \"Google Chrome\" to do shell脚本\"/usr/local/bin/cliclick c:360\,550\"'
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-07-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-22
    • 1970-01-01
    相关资源
    最近更新 更多