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 6001919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:54:13+00:00 2026-05-23T00:54:13+00:00

I tried to use Application Scripting Bridge to send my Mac to sleep. The

  • 0

I tried to use Application Scripting Bridge to send my Mac to sleep.
The code look like the following:

#import "Finder.h"
 FinderApplication *Finder = [SBApplication applicationWithBundleIdentifier:@"com.apple.finder"];
        [Finder sleep];

But it doesn’t work. Any ideas why it doesn’t work? No compiling errors or warnings, but it doesn’t work…

  • 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-23T00:54:14+00:00Added an answer on May 23, 2026 at 12:54 am

    As I posted in this answer, I’ve been using the following code for over 8 years without issues:

    MDRestartShutdownLogout.h:

    #import <CoreServices/CoreServices.h>
    /*
        *    kAERestart        will cause system to restart
        *    kAEShutDown       will cause system to shutdown
        *    kAEReallyLogout   will cause system to logout
        *    kAESleep          will cause system to sleep
     */
    extern OSStatus MDSendAppleEventToSystemProcess(AEEventID eventToSend);
    

    MDRestartShutdownLogout.m:

    #import "MDRestartShutdownLogout.h"
    
    OSStatus MDSendAppleEventToSystemProcess(AEEventID eventToSendID) {
        AEAddressDesc targetDesc;
        static const ProcessSerialNumber kPSNOfSystemProcess = {0, kSystemProcess };
        AppleEvent eventReply = {typeNull, NULL};
        AppleEvent eventToSend = {typeNull, NULL};
    
        OSStatus status = AECreateDesc(typeProcessSerialNumber,
             &kPSNOfSystemProcess, sizeof(kPSNOfSystemProcess), &targetDesc);
    
        if (status != noErr) return status;
    
        status = AECreateAppleEvent(kCoreEventClass, eventToSendID,
              &targetDesc, kAutoGenerateReturnID, kAnyTransactionID, &eventToSend);
    
        AEDisposeDesc(&targetDesc);
    
        if (status != noErr) return status;
    
        status = AESendMessage(&eventToSend, &eventReply,
                              kAENormalPriority, kAEDefaultTimeout);
    
        AEDisposeDesc(&eventToSend);
        if (status != noErr) return status;
        AEDisposeDesc(&eventReply);
        return status;
    }
    

    Note that the above code is based on the code from Technical Q&A QA1134, but mine is re-worked to use AESendMessage() rather than AESend(). AESend() is in HIToolbox.framework, which is in Carbon.framework and is therefore unavailable to 64-bit apps. (AESendMessage() is part of the AE.framework in CoreServices).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that traces program execution through memory. I tried to use
I'm trying to control Safari windows from my application. I use this code to
I am trying to use comments application in my project. I tried to use
I tried to use the WebBrowser control in an ASP .NET application: public BrowserForm()
I have tried to use Webgrind for profiling my application but when I click
I have tried to use: .htaccess <Files client> ForceType application/x-httpd-php </Files> client file <?php
I'm developing an application for Android, and have tried to use ORMLite, but the
In WinForms, I'd use Application.ProductVersion . I've tried using System.Reflection.Assembly in various ways but
I tried to use Zend_Test_PHPUnit to write unit tests for my application, but I
Has anybody tried to use JavaFX Script in server side applications? The language itself

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.