2

we are trying to automate the SecurityAgent dialog where we are inputting password using pyautogui in 10.13 OSx

password = "12345678" using

pyautogui.typewrite(password)

this function solved the problem. However, we are running this script many number of times in the same machine

Am not sure if it is because of the machine slowness or something , only 7 characters are getting written on the screen and enter is clicked which fails the step.

i also tried adding interval and pause value in pyautogui. But it doesnt help. Randomly script is failing.

Instead of typing a whole sequence i tried to run a loop like below

for c in password:
  pyautogui.press(c)

Still it didnt help. Can someone help with the alternate solution ?

2

With AppleScript I made this for use in Automator:

https://gist.github.com/SuperHofstad/f826985ec536ff2d650699cb37a7fadc

set appPass to "PASSWORD" as text

tell application "System Events"
    delay 0.5
    repeat until exists process "SecurityAgent"
        delay 0.5
    end repeat
    tell process "SecurityAgent"
        keystroke appPass
        key code 36
    end tell
end tell
  • Not perfect, but the code is a start. Might get around to make it better some other time.. – Petter Hofstad Jan 17 at 3:27
0

You may be typing too fast. Try pyautogui.typewrite(password, interval=0.2)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .