Reputation: 1
I wrote a simple AppleScript to unlock my Macbook Pro (running 10.11) and it doesn't work:
on run argv
set pword to (item 1 of argv)
tell application "System Events"
key code 125
delay 1
keystroke return
delay 1
keystroke pword
delay 1
keystroke return
end tell
end run
I execute it by calling osascript myscript.scpt my_password
At first I thought it's not getting my password from the argument, but I added a log command and it printed my password, so I am not sure why it isn't working. My original code was
on run argv
set pword to (item 1 of argv)
tell application "System Events"
keystroke pword
delay 1
keystroke return
end tell
end run
but that didn't work as well. I modified it because you need to press down key and then press enter to select the first user on the lock screen and display the textbox to type the password, so I added the command to press down key and then return key.
Anyone have any clue regarding why it doesn't work?
NOTE: It works when I resume my Mac from sleep or screensaver, but not from the fast user switch UI ('Login Window...' option)
Upvotes: 0
Views: 835
Reputation: 35
I think that when your locked out of your account it doesn't let anything process from your computer until login. Cause technically you could use that to break into a computer. Maybe you should try another script or making it deactivate the password temporarily and then press enter!
Upvotes: 1