【问题标题】:How to enter password for prompt windows using applescript如何使用applescript为提示窗口输入密码
【发布时间】:2013-05-30 06:33:18
【问题描述】:

我是 applescript 的新手,目前卡在访问提示窗口询问我的密码。

我正在为我的日常使用应用程序创建一个启动器,并且我想自动化启动过程。

现在,我只启动两个应用程序,VirtualHostX 和 MAMP。稍后我可能会添加一些。

这是我到目前为止所做的:

tell application "VirtualHostX" to activate
tell application "MAMP" to activate

tell application "System Events"
    tell process "VirtualHostX"
        tell menu bar 1
            tell menu bar item "Web Server"
                tell menu 1
                    click menu item "Start"
                end tell
            end tell
        end tell
    end tell
end tell

启动时,会成功启动这两个应用程序,但虚拟主机会询问我的密码以进行授权。我想在流程或代码中集成输入我的密码。我已经尝试谷歌寻求答案,但未能找到解决方案。

我似乎无法定位该窗口并输入我的密码。

让我知道我错过了什么。

谢谢。

【问题讨论】:

    标签: automation applescript


    【解决方案1】:

    SecurityAgent 显示密码对话框:

    tell application "System Events" to tell process "SecurityAgent"
        set value of text field 2 of scroll area 1 of group 1 of window 1 to "password"
        click button 2 of group 2 of window 1
    end tell
    

    【讨论】:

    • 工作就像一个魅力,劳里。
    • 我认为优胜美地发生了一些事情,这使得它不再起作用。有什么建议吗?
    【解决方案2】:

    对于 Yosemite,SecurityAgent 对话框有所不同。这将起作用:

    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
    

    【讨论】:

      猜你喜欢
      • 2017-04-13
      • 2019-05-01
      • 2018-10-17
      • 2023-03-19
      • 2012-09-24
      • 2016-08-27
      • 2014-09-26
      • 2018-09-23
      相关资源
      最近更新 更多