Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enter password for prompt windows using applescript

I'm new to applescript and is currently stuck in access the prompt window asking for my password.

I'm creating a launcher for my daily use application and i want to automate the launching process.

Right now, I'm only launching two application, VirtualHostX and MAMP. Later I might add few some.

Here's what I done so far:

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

When launching, It will launch the two application successfully, but Virtual Host will ask me for my password for authorization. I want to integrate entering my password in the flow or code. I already tried to google for answer but failed to find a solution for it.

I can't seem to target that window and enter my password. enter image description here

Let me know what am I missing.

Thank You.

like image 911
Pennf0lio Avatar asked Mar 23 '23 18:03

Pennf0lio


1 Answers

Password dialogs are shown by 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
like image 123
Lri Avatar answered Apr 27 '23 07:04

Lri