I have written a program that pops up in front of the loginwindow app and asks for certain information. Once the information is validated. The loginwindow can be seen and u can select which user to log in. I want to run script/bash code or something within my app so that the user does not get the chance to see the loginwindow. Instead, the application should login the guest user itself. I tried using applescript i.e
set logInUser to "Guest"
set logInPassword to "Guest"
tell application "System Events"
tell application process "loginwindow"
key code 53
delay 1
key code 125
delay 1
key code 36 using option down
delay 1
keystroke tab
delay 1
key code 117
delay 0.5
keystroke tab
delay 0.5
key code 117
keystroke return
delay 1
keystroke tab
delay 0.2
repeat with aChar in characters of logInUser
keystroke aChar
delay 0.2
end repeat
keystroke tab
delay 0.5
repeat with aChar in characters of logInPassword
keystroke aChar
delay 0.2
end repeat
key code 98 using control down
delay 0.2
keystroke return
end tell
end tell
Since loginwindow is not responding to this applescript, i开发者_如何学Python tried bash too but nothing is work. Any help would be great. :(
It would be useful to know what you're really trying to do here. The supported way to inject synchronous events during login is with an authentication hook. This is much more powerful than trying to "run in front of LoginWindow." The problem with interrupting loginwindow
is that you need to deal with the cases of logout and fast-user-switch. You can also use loginwindow's LoginHook to run a script before login is completed. But again, these are all after the user has entered their credentials (in the case of LoginHook
, it's after the credentials have been validated).
That said, the best place to put something before LoginWindow is to create an old-style SystemStarter
daemon in /Library/StartupItems
. These are run synchronously before loginwindow
, but just during initial startup (not after logout or during FUS).
精彩评论