Help making a script to put my computer back to the login window

Hi everybody! :slight_smile:

Im am VERY new to scripting, and have only done some basic things with Automator so far. I was really hoping someone could help me write a scrip that locks my computer by bringing me back to the loging screen. Those of you who have multiple users on your mac, or those who just like to lock your computer will know that in System Preferences - Accounts - Login Options, you can select ‘Enable Fast User Switching’ which even if you dont have multiple users, puts a little icon up the top right, next to the Spotlight icon, which has the feature “Login Windonw…” which when selected takes you back to the login window WITHOUT quitting your applications etc. In this way it is different from actually loggin out, but at the same time prevents any unwanted use of your computer.

What I would like to do is to write a script that executes this command so that I can use it with the Automator program, but to be honest I have no idea where to start?!!

Any help with this would be greatly appreciated!

Thanks in advance
Tim:)

Model: PowerBook 15"
AppleScript: AppleScript 1.10.7
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

Hi Tim,

In Automator select the action Automator > Run Shell Script. In the box that says ‘cat’ enter the following line.

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

Best wishes

John M

Hi!

Thanks heaps! :smiley: That works perfectly! haha now il just have to work out why it works! haha! Thanks again!

Tim:D

Model: PowerBook 15"
AppleScript: AppleScript 1.10.7
Browser: Safari 419.3
Operating System: Mac OS X (10.4)

Hi Tim,

I’m glad it helped.

I’m not 100% certain on the ins and outs of why it works, but what it is doing is running the script (application?) CGSession (located in the path stated) with the option suspend.

Best wishes

John M

Hi again!

Yeah thanks for that, i followed the trail and found the ‘application’ or scrip of whatever it is! Sorry to keep pestering but how did u find that? Have you made the same workflow, or is there a way of finding what scrips run differend system commands. I know how to find the parts of programs, but the actual OS is so complex?

Anyway thankyou so much, as it works perfectly!

Hi Tim,

I can’t remember where I picked it up from, it’s been hanging around in an Applescript I had from a few years ago.

See:
http://lists.apple.com/archives/Applescript-users/2006/Aug/msg00291.html
and:
http://www.macosxhints.com/article.php?story=20031102031045417

John M

Ahh cool!

Thanks so much! U have been really helpful, and I really appreciate that you have taken the time to help me!

Thanks again!

Tim

I have system preferences (under the Apple in upper left corner) set up so that password is required to get past the screen saver (check box under security).

Next, set up a hot corner to turn on screen saver (system preferences, desktop and screen saver, hot corners… or dashboard and expose’).

When you get up to leave, drag the mouse into the appropriate corner… the screen saver will come on immediately, and then anyone wishing to access the computer will have to enter a password.

No Scripts required. Part of OS X.

David