0
我将TextEdit中的文本存储在AppleScript变量中,我想将它传递给JavaScript。我认为我做得对,但我仍然无法获得存储的价值。代码如下:传递给JavaScript的AppleScript变量
tell application "TextEdit"
activate
set docText to the text of the front document --This works. I've checked.
end tell
tell application "Google Chrome"
tell window 1
tell active tab
execute javascript "function encryptDocument() {
plainText = '" & docText & "';
return plainText;
} encryptDocument();"
set skurp to the result
display dialog skurp
end tell
end tell
end tell
我容纳tell application "Google Chrome"
命令中的JavaScript代码的原因是因为我得到每次我尝试调用它以前的tell application "TextEdit"
命令时出错。该错误总是表示它期望行结束,但发现"
。不知道为什么,但我无法找到解决这个问题的方法。
你知道,我虽然关于从来没有,但是这是确切的原因。谢谢!看来我需要改变我的真实代码中的一些东西。 – Josh 2012-08-07 14:13:30
你知道一种逃避单引号的方法吗? – Josh 2012-08-07 15:26:52
我编辑过的答案包括一些苹果脚本来逃避单引号。我没有立即发现可以做同样的内建函数。 – Vortexfive 2012-08-07 18:39:47