How to switch to login window using obj-c on Mac OS 10.6+

I have an app and I need to navigate to a Login window programmatically similar to this app: http://itunes.apple.com/us/app/lock-me-now/id464265594?mt=12

Thank.

+3


source to share


2 answers


If you want to switch user:

/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -switchToUserID UserID

      

for UserID



id -u userName

      

For login window

/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend

      

+2


source


You are sending the Apple event "aevtlogo" Apple to the application loginwindow

. Have a look at the documentation for the classes NSAppleEvent<Foo>

.



+3


source