我找不到如何将所选文本作为AppleScript和Automator的变量使用。
有任何想法吗?
有任何想法吗?
对于Applescript,它可以与其他应用程序一起使用。要获取应用程序前窗口中所选文本,Applescript必须使用该应用程序理解/响应的语言/语法。对于非常可脚本化、基于文本文档的应用程序,它们之间有很多相似之处,看起来像:
tell app "xyz" to get selection of document 1
tell application "Safari" to set selectedText to (do JavaScript "(''+getSelection())" in document 1)
tell application "System Events" to tell application process "TextEdit" to tell attribute "AXSelectedText" of text area 1 of scroll area 1 of window 1 to set selectedText to its value
tell application "Microsoft Word" to set selectedText to content of text object of selection
tell application "System Events" to keystroke "c" using {command down}
delay 1
set selectedText to the clipboard
文本
”。然后,你就可以使用Automator操作与传递给后续操作的所选文本进行交互。不幸的是,并非所有程序都兼容服务。on run {input, parameters}
display dialog (input as text)
return input
end run