Macos 如何使用applescript从1Password复制密码内容?
本文介绍了如何启动1Password mini并从applescript中选择密码。作为跟进,如何将密码内容复制到剪贴板?applescript中的命令应该是什么 1 Password Mini似乎没有API,因此我们必须在整个过程中摸索 这里有一种方法:Macos 如何使用applescript从1Password复制密码内容?,macos,applescript,Macos,Applescript,本文介绍了如何启动1Password mini并从applescript中选择密码。作为跟进,如何将密码内容复制到剪贴板?applescript中的命令应该是什么 1 Password Mini似乎没有API,因此我们必须在整个过程中摸索 这里有一种方法: set theSearchTerm to "facebook" -- Search for the password in 1Password do shell script "open x-onepassword-helper://sea
set theSearchTerm to "facebook"
-- Search for the password in 1Password
do shell script "open x-onepassword-helper://search/" & theSearchTerm
delay 0.5
-- Copy to clipboard
tell application "System Events" to keystroke "c" using {shift down, command down}
delay 0.5
-- Ensure password is copied as pasteable text
do shell script "pbpaste | pbcopy"
-- Use the password
set thePassword to (the clipboard as text)
有几个问题需要注意:
“pbpaste | pbcopy”
行,文本在90秒后不会自动删除。(没有此步骤,我无法使脚本正常工作)set theSearchTerm to "foo"
set thePassword to ""
-- Search for the password in 1Password
open location "x-onepassword-helper://search/" & theSearchTerm
delay 0.5
tell application "System Events" to tell process "1Password mini"
set theClipboardTextPre to (the clipboard as text)
-- Copy to clipboard
keystroke "c" using {shift down, command down}
delay 0.5
-- Ensure password is copied as pasteable text
do shell script "pbpaste | pbcopy"
-- Check to see if clipboard contents have changed
-- If no change, it implies 1Password didn't return a search result
set theClipboardTextPost to (the clipboard as text)
if theClipboardTextPre is not equal to theClipboardTextPost then
set thePassword to theClipboardTextPost
end if
end tell
log thePassword
这里的缺点是,如果您有两个使用相同密码的站点,脚本会认为1Password没有返回搜索结果。@Agilebbits\u Jasper既然您已经回答了链接问题,您还知道如何将CMD+C发送到1Password吗?非常感谢。