简体   繁体   English

解锁锁屏AppleScript不起作用

[英]Unlock lock screen AppleScript not working

I wrote a simple AppleScript to unlock my Macbook Pro (running 10.11) and it doesn't work: 我编写了一个简单的AppleScript来解锁我的Macbook Pro(运行10.11),但是它不起作用:

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 我通过调用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. 起初我以为它不是从参数中获取密码,但是我添加了一个log命令并打印了密码,所以我不确定为什么它不起作用。 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. 我进行了修改,因为您需要按向下键,然后按Enter键以在锁定屏幕上选择第一个用户,并显示文本框以键入密码,因此我添加了先按向下键再返回键的命令。

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) 注意:当我从睡眠或屏幕保护程序中恢复Mac,但不能从快速用户切换UI(“登录窗口...”选项)恢复Mac时,它可以工作

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! 也许您应该尝试使用另一个脚本或使其暂时停用密码,然后按Enter!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM