求救!!!通过命令行 如何给 弹出框发送 输入的内容 和点击事件?

expect 如何给 弹出框发送 输入的内容 和点击事件? 通过脚本自动填充密码,发送点击事件?
如图

https://stackoverflow.com/questions/16829450/how-to-enter-password-for-prompt-windows-using-applescript

很久之前我看到一个脚本可以,现在找不到了。好像是 expect 但是我不知道怎么给这个密码框发送密码。

下面不是给了例子吗:

tell application "System Events"
    tell process "SecurityAgent"
        set value of text field 2 of window 1 to "yourPassword"
        click button 2 of window 1
    end tell
end tell

把yourpassword替换成你的密码就好了,我猜

1 个赞

不过你为什么不用image

echo "your password" | security unlock-keychain ~/Library/Keychains/login.keychain

have a try

看你吧expect都折腾上了,, expect适用于那种命令行交互需要延迟输密码的地方。比如跳个堡垒机之类的。

3 个赞

嗯 非常感谢!!

谢谢 我的问题解决了!

nb紫薯布丁

:star_struck: 被张总翻牌子了,哈哈哈哈

where is the 布丁?

1 个赞

n ⁠ ⁠