在 PDF 中查找字符,return 个整个单词
Find characters in PDF, return whole word
抱歉,我的 AppleScripting 知识非常基础,但是,我了解一般脚本,因为我有 PowerShell 知识。
我想要一行简单的脚本来搜索打开的 PDF 中的字符,例如“Lon”和 return 整个单词,例如“伦敦”作为变量。
如果你想嘲笑我可悲的尝试,请看下面:
tell application "Preview"
set newfile to (get word 1 of text of "Lon*")
end tell
提前致谢
Preview 不能很好地使用基本 vanilla AppleScript 编写脚本,但是,以下 example AppleScript code 使用 Skim 作为 PDF Reader,并且可以做你想做的事:
considering case
tell application "Skim" to ¬
set the targetWord to the first word of ¬
the text of the front document where it starts with "Lon"
end considering
注意:示例 AppleScript code 就是这样,没有包含任何 错误处理 不包含任何额外的 错误处理 可能是适当的。用户有责任根据需要或需要添加任何 错误处理 。查看 try statement and error statement in the AppleScript Language Guide. See also, Working with Errors. Additionally, the use of the delay 命令 在适当的事件之间可能是必要的,例如delay 0.5
,适当设置延迟的值。
抱歉,我的 AppleScripting 知识非常基础,但是,我了解一般脚本,因为我有 PowerShell 知识。
我想要一行简单的脚本来搜索打开的 PDF 中的字符,例如“Lon”和 return 整个单词,例如“伦敦”作为变量。
如果你想嘲笑我可悲的尝试,请看下面:
tell application "Preview"
set newfile to (get word 1 of text of "Lon*")
end tell
提前致谢
Preview 不能很好地使用基本 vanilla AppleScript 编写脚本,但是,以下 example AppleScript code 使用 Skim 作为 PDF Reader,并且可以做你想做的事:
considering case
tell application "Skim" to ¬
set the targetWord to the first word of ¬
the text of the front document where it starts with "Lon"
end considering
注意:示例 AppleScript code 就是这样,没有包含任何 错误处理 不包含任何额外的 错误处理 可能是适当的。用户有责任根据需要或需要添加任何 错误处理 。查看 try statement and error statement in the AppleScript Language Guide. See also, Working with Errors. Additionally, the use of the delay 命令 在适当的事件之间可能是必要的,例如delay 0.5
,适当设置延迟的值。