我正在尝试使用AppleScript自动执行Numbers和Quicken 2017之间的重复任务。
我想在Numbers中获取当前所选单元格的内容,使用该数值设置剪贴板,并将该值粘贴到Quicken中的搜索字段中。
如何用AppleScript做到这一点?
用于说明意图的示例伪代码:
tell application "Numbers"
activate
set myCellsValue to value of currently selected cell
set the clipboard to myCellsValue
end tell
tell application "Quicken 2017"
activate
tell application "System Events"
keystroke "f" using {command down}
delay 0.1
keystroke "v" using {command down}
end tell
end tell
答案 0 :(得分:0)
你得到了90%的正确率。我不使用Quicken,但这适用于Microsoft Word:
tell application "Numbers"
activate
tell active sheet to tell application "System Events" to keystroke "c" using command down
end tell
tell application "Quicken 2017"
activate
tell application "System Events"
keystroke "f" using command down
delay 0.1
keystroke "v" using command down
end tell
end tell
答案 1 :(得分:0)
如果还有其他方法,我通常希望尽量减少使用系统事件发出击键或鼠标点击的数量。
数字非常适合AppleScript。我没有亲自使用它,但在this site的帮助下,我将这个示例脚本拼凑在一起,我完全承认这是未经测试的(我'如果您尝试一下,请欣赏您的反馈意见):
tell application "Numbers"
tell the front document to ¬
tell the active sheet to ¬
set CurrentTable to the first table whose class of selection range is range
tell the CurrentTable to get the value of the first cell in the selection range
if the result is not missing value then set the clipboard to the result
end tell
Quicken 也是AppleScript的,但我找不到 Quicken 的AppleScript字典的可下载副本,以便拼凑出等效的代码示例。但是,您的 Quicken tell
块完全适合使用系统事件来发出 Cmd + V
但是,如果您想要上传AppleScript字典的PDF,我可以用它来尝试更强大的功能。