大家好.在Mac OSX 10.6上工作,我的"问题"是我希望在我的用户帐户上使用安全密码,但是不管是否需要在进程需要管理员权限时粘贴它就会遇到麻烦.
我使用Autopilot,并认为这是输入它的最佳方式,因此我可以使用直接的AppleScript输入,2使用带有"osascript ..."的shell脚本.3启动AppleScript编译的应用程序4使用自动驾驶仪中的文本扩展功能(在这种情况下似乎不起作用)
我到目前为止的脚本是:
set the clipboard to "FooBar"
set resultAnything to the clipboard as text
Run Code Online (Sandbox Code Playgroud)
当我在脚本编辑器中执行时,我的结果是"FooBar"但是我不能让它在其他任何地方工作.
我不能用
set the clipboard to "FooBar"
tell application "System Events"
keystroke "v" using command down
end tell
Run Code Online (Sandbox Code Playgroud)
因为密码对话框似乎没有接受命令+ v paste方法.
有帮助吗?顺便说一下,在发布这个问题之前,我确实在网上和stackoverflow上进行了搜索,所以如果我忽略了已经发布的内容,请原谅我.
谢谢
pft*_*221 10
安全方面,最好将密码存储在登录密钥链中,并在需要时从那里检索密码.(这样您必须登录才能使密码可用.如果您只是将密码保存在AppleScript中,那么任何有权访问applescript文件的人都可以访问该密码.)
请尝试以下方法:
代码:
set keyName to "myKeyname" -- replace myKeyname with the Keychain Item Name from step 3
tell application "Keychain Scripting"
tell keychain "login.keychain"
set myPass to password of (some key whose name is keyName)
end tell
end tell
tell application "System Events"
keystroke myPass
end tell
Run Code Online (Sandbox Code Playgroud)
积分:
| 归档时间: |
|
| 查看次数: |
3364 次 |
| 最近记录: |