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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:54:43+00:00 2026-05-26T16:54:43+00:00

I am developing Mac desktop application, where I am capturing the screen using CGImageRef

  • 0

I am developing Mac desktop application, where I am capturing the screen using

CGImageRef screenShot = CGWindowListCreateImage(CGRectInfinite, kCGWindowListOptionAll, kCGNullWindowID, kCGWindowImageDefault);

The problem is, I am expecting it should show the mouse cursor too, but it’s not showing.

Do I need to enable any settings for that?

I tried the following before calling this function:

CGDisplayShowCursor(kCGDirectMainDisplay);
    
CGAssociateMouseAndMouseCursorPosition(true);

, but it didn’t work.

When I checked using following

bool bCursor = CGCursorIsDrawnInFramebuffer(); /* This returns false */

bCursor = CGCursorIsVisible();  /* This returns true */

, te value says the cursor was not drawn in the frame buffer, however the cursor is visible.

I suppose I only need to do is to draw the cursor in the frame buffer, how do I do this?.

  • 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-26T16:54:43+00:00Added an answer on May 26, 2026 at 4:54 pm

    it seems, framebuffer doesn’t give me the mouse cursor, so i am drawing my own, this is the code snippet , might be help full to you guys,

    -(CGImageRef)appendMouseCursor:(CGImageRef)pSourceImage{
        // get the cursor image 
        NSPoint mouseLoc; 
        mouseLoc = [NSEvent mouseLocation]; //get cur
    
        NSLog(@"Mouse location is x=%d,y=%d",(int)mouseLoc.x,(int)mouseLoc.y);
    
        // get the mouse image 
        NSImage *overlay    =   [[[NSCursor arrowCursor] image] copy];
    
        NSLog(@"Mouse location is x=%d,y=%d cursor width = %d, cursor height = %d",(int)mouseLoc.x,(int)mouseLoc.y,(int)[overlay size].width,(int)[overlay size].height);
    
        int x = (int)mouseLoc.x;
        int y = (int)mouseLoc.y;
        int w = (int)[overlay size].width;
        int h = (int)[overlay size].height;
        int org_x = x;
        int org_y = y;
    
        size_t height = CGImageGetHeight(pSourceImage);
        size_t width =  CGImageGetWidth(pSourceImage);
        int bytesPerRow = CGImageGetBytesPerRow(pSourceImage);
    
        unsigned int * imgData = (unsigned int*)malloc(height*bytesPerRow);
    
        // have the graphics context now, 
        CGRect bgBoundingBox = CGRectMake (0, 0, width,height);
    
        CGContextRef context =  CGBitmapContextCreate(imgData, width, 
                                                      height, 
                                                      8, // 8 bits per component 
                                                      bytesPerRow, 
                                                      CGImageGetColorSpace(pSourceImage), 
                                                      CGImageGetBitmapInfo(pSourceImage));
    
        // first draw the image 
        CGContextDrawImage(context,bgBoundingBox,pSourceImage);
    
        // then mouse cursor 
        CGContextDrawImage(context,CGRectMake(0, 0, width,height),pSourceImage);
    
        // then mouse cursor 
        CGContextDrawImage(context,CGRectMake(org_x, org_y, w,h),[overlay CGImageForProposedRect: NULL context: NULL hints: NULL] );
    
    
        // assuming both the image has been drawn then create an Image Ref for that 
    
        CGImageRef pFinalImage = CGBitmapContextCreateImage(context);
    
        CGContextRelease(context);
    
        return pFinalImage; /* to be released by the caller */
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing an Mac Desktop application. I have the problem related to Spaces
I'm developing a mac application in C++, and I'm having the following problem: words(26222,0xa0b5c540)
I'm using Eclipse on mac for developing android apps. When I run the application
I'm developing a desktop application using Java. I want to put an icon (with
I'm developing a desktop Mac OS X App that saves its very simple data
I am developing an application for the Mac as a small team (me +
I am developing a Web application in Pylons on the Mac. My development server
I'm developing both a Java app and J2EE webapp using Eclipse Europa on Mac
I'm developing small FTP upload app. for mac (10.6 if it matters) Have problem
Anyone know application like network location(mac) for linux,windows.If not i am thinking of developing

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.