【问题标题】:Why can't pass my variable to applescript?为什么不能将我的变量传递给applescript?
【发布时间】:2019-03-04 00:04:11
【问题描述】:

屏幕截图显示了我是如何尝试执行此操作的。我似乎无法将捕获的变量传递给 applescript。我是 applescript 的新手,所以它可能是一些非常基本的东西让我绊倒。

基本语法或类似的东西。目前传递的是文本'(input02)',而不是变量。

用谷歌搜索过,没有运气。有什么想法吗?

【问题讨论】:

    标签: applescript automator


    【解决方案1】:

    我发现 Automator 工作流程 和 OP 中的 AppleScript 代码 有一些问题。

    AppleScript 代码中:

    在第二个Run AppleScript action中,OP中包含的图片,code应该如下:

    on run {input, parameters}
        set input02 to (input as text)
        delay 2
        tell application "Google Chrome"
            execute front window's active tab javascript ¬
                "document.getElementById('title').value = '" & input02 & "';"
            execute front window's active tab javascript ¬
                "document.getElementById('wmd-input').value = 'body copy goes here';"
        end tell
    end run
    
    • 在第一行execute中,'(inputs02)' 更改为'" & input02 & "',从而允许它实际传递input02 变量。正如最初编码的那样,它传递的是文字input02 而不是input02 变量,因为它是在两个引号之间捕获的,并且括号不是必需的。在这个用例中,将 variable& 符号 连接起来而不用引号将其括起来使其成为 variable 而不是 literal。 (您会在下图中看到变量代码高亮显示。)

    Automator 工作流程中:

    在下图中,注意两个操作选项设置,其中
    [√]忽略此操作输入被检查。这会在它和之前的action 之间造成脱节,从而忽略它的input。查看亮点,与下面的 action 相比,它不再连接。

    勾选了[√]Ignore this actions inputactions不应该直接将任何信息传递给下一个action,因为在这个用例中,它们应该独立于后续的action

    【讨论】:

    • 美丽。感谢您的详细回答。
    猜你喜欢
    • 1970-01-01
    • 2012-02-13
    • 2011-02-05
    • 1970-01-01
    • 1970-01-01
    • 2019-05-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-15
    相关资源
    最近更新 更多