Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6659175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:00:06+00:00 2026-05-26T02:00:06+00:00

Is it possible to write an AppleScript to put the display to sleep (which

  • 0

Is it possible to write an AppleScript to put the display to sleep (which locks the display if the computer is set to lock on sleep)? You can do this from the keyboard by entering ⌃⇧⏏ (shift+control+eject); this leaves all the programs, etc., running, and just turns off the screen.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:00:07+00:00Added an answer on May 26, 2026 at 2:00 am

    Edit 2015-08-23: This is possible (from the shell) as of OS X 10.9! Go see user3064009’s answer for the update 🙂


    There’s no good way to do this; there’s a SuperUser question about this same thing. Depending on why you want this, however, there’s one workaround I know: activate the screen saver. (This is what they suggest over on SuperUser). You can do this in AppleScript with launch application id "com.apple.ScreenSaver.Engine", or from the command line by running the application /System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine. I don’t know whether or not this is technically documented anywhere, but it’s worked for several iterations of the OS now. It may not do exactly what you want—your screen saver may, for instance, be colorful, which isn’t helpful if you want a black screen—but it will be the same in that it does lock the screen if you have that set up.

    For a nice catalog of other workarounds, check out this MacScripter thread: it documents that

    • There’s no scriptable way to do this.
    • You can’t tell AppleScript to key code EJECT, as there’s no such key code.
    • You can use pmset to tell the display to go to sleep in one minute, but then you have to wait.
    • There’s an undocumented IOKit way to do this; there’s a mailing list post explaining how.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to write a macro which can take in a variable number
Would it be possible to write a class that is virtually indistinguishable from an
It is possible to write a Regex which needs in some cases exponential running
Is is possible to write to the http response stream from a dynamically created
Question: Is it possible to write a C# dll that can be pinvoked ?
is it possible to write a bash script that can read in each line
Is it possible to write an inline generic method? For example, how can I
Is it possible to write a GUI from inside a function? The problem is
Is it possible to write code like this? public void DoSomeOperation().Log() { }.Log() Above
Is it possible write a field size on Model? This is part of my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.