我搜索过高低,无法找到答案。
如何将Chrome中的网址复制并粘贴到Excel中?
基本上,我有一个项目正在工作,我必须将值复制并粘贴到搜索引擎中。我必须保存该搜索结果的URL。我不知道如何使用Applescript做到这一点。这是我到目前为止的代码。我知道它不优雅,但我会感激任何帮助!
告诉应用程序“Microsoft Excel”激活
告诉应用程序“系统事件”
tell process "Microsoft Excel"
keystroke "c" using command down
end tell
告诉
延迟0.4
告诉应用程序“Google Chrome”激活
告诉应用程序“系统事件”
tell process "Google Chrome"
keystroke "a" using command down
keystroke "v" using command down
end tell
delay 0.5
tell application "System Events"
tell process "Google Chrome"
keystroke return
end tell
end tell
delay 5.0
tell application "Google Chrome"
get URL of active tab of first window as text
end tell
delay 5.0
tell application "System Events" to keystroke "w" using command down
告诉
告诉应用程序“Microsoft Excel”激活
告诉应用程序“系统事件”
tell process "Microsoft Excel"
keystroke tab
keystroke "v" using command down
keystroke down
keystroke left
end tell
告诉
答案 0 :(得分:0)
脚本本身似乎有点古怪,因为你使用了大量不必要的UI脚本。这说解决方案(对于您的脚本)是,您复制网址并将其粘贴到浏览器中。过了一会儿,你想要读取网址并将其粘贴到初始网址旁边的单元格中。您忘记在该步骤之前复制该网址。如果使用keystroke "v" using command down
粘贴,则只有初始网址存储在剪贴板中。
如果您希望脚本以这种方式工作,则必须更改行
get URL of active tab of first window as text
到
set the clipboard to (URL of active tab of first window as text)
但是:我强烈建议您使用目标应用程序的完整可能性(即字典)来重新创建脚本!你只能用香草苹果来实现你的目标!