shellautomationautocompletepasswordsapplescript

Is there a way to automatic introduce the mac password using appleScript_


I have wrote code to make a bit faster introduce the time from promodoro in selfcontrol based on the intervals. However I couldn't introduce automatic, it just open the dialog to put the password. password input

tell application "WebPomodoro"
    activate
end tell
set input to text returned of (display dialog "Ingresa un número para el Pomodoro:" default answer "" with icon note buttons {"Continue"} default button "Continue")

try
    set inputNumber to (input as integer)
on error
    display dialog "El texto ingresado no es un número válido."
end try

set total_time to 0

repeat with interval from 1 to inputNumber
    set total_time to total_time + 25
    if interval mod 4 = 0 then
        set total_time to total_time + 25
    else
        set total_time to total_time + 5
    end if
end repeat

set hours to (total_time div 60)
set minutes to (total_time mod 60)
display dialog (hours as string) & " horas y " & (minutes as string) & " minutos"

delay 2
tell application "SelfControl"
    activate
end tell
delay 15 --set time

set myPassword to "password"

tell application "System Events"
    -- Buscar el cuadro de diálogo de SelfControl
    tell process "SelfControl"
        keystroke myPassword
        keystroke return
    end tell
end tell

Solution

  • No, for very good reason, you wouldn't want any random script to be able to just, grab your password, would you? In fact you wouldn't want the system to store your password for any reason any longer than it absolutely has to.

    At least on my system however, as long as you have the password in AppleScript you can enter that into the password prompt.

    Of course, you could just hardcode that password into the script, but that's not great for security, so you might want to store the password in the Keychain.

    To do that, first you'll need to open 'Keychain Access', and hit Cmd+N to create a new entry. Enter something memorable in 'Keychain Item Name', you'll need it later, and enter anything into 'Account Name' (it doesn't matter). Enter your password into 'Password'.

    Then you can try something like: do shell script "security find-generic-password -s 'name-of-keychain-entry' -w".