将多个Applescript变量传递给Ruby
我正在编写一个Ruby脚本,它需要来自Applescript的一些变量。现在,我成功地一次抓住一个,但这似乎不雅观,而且可能很慢。例如:将多个Applescript变量传递给Ruby,ruby,variables,applescript,Ruby,Variables,Applescript,我正在编写一个Ruby脚本,它需要来自Applescript的一些变量。现在,我成功地一次抓住一个,但这似乎不雅观,而且可能很慢。例如: note = %x{ osascript <<APPLESCRIPT tell application "Evernote" if selection is not {} then set the_selection to selection if notebook of it
note = %x{ osascript <<APPLESCRIPT
tell application "Evernote"
if selection is not {} then
set the_selection to selection
if notebook of item 1 of the_selection is (notebook named "Writing") then
return HTML content of item 1 of the_selection
end if
else
return ""
end if
end tell
APPLESCRIPT}
title = %x{ osascript <<APPLESCRIPT
tell application "Evernote"
if selection is not {} then
set the_selection to selection
if notebook of item 1 of the_selection is (notebook named "Writing") then
return title of item 1 of the_selection
end if
else
return ""
end if
end tell
APPLESCRIPT}
note=%x{osascript从AppleScript中获取多个值是最简单的部分。与其返回单个值,不如返回一个列表:
result=%x{osascript<看起来很方便。这很好,只需一个语法更改:Applescript逐字解释“/n”,因此当你在编辑器中编译脚本时,它实际上会在那里添加一行。在Applescript中,“linefeed”是等效的。我使用了它,然后在Ruby脚本中按“/n”拆分,一切都很正常。