user3692208
user3692208

Reputation: 39

Add to Screenshot mouse cursor in C#

Hi I have a function in c# to get a screenshot of poor quality so that the image does not weigh much, I have it all figured out but the problem is that the screenshot does not see the mouse cursor.

the code is this:

    int screenWidth = Screen.GetBounds(new Point(0, 0)).Width;
    int screenHeight = Screen.GetBounds(new Point(0, 0)).Height;
    Bitmap bmpScreenShot = new Bitmap(screenWidth, screenHeight);
    Graphics gfx = Graphics.FromImage((Image)bmpScreenShot);
    gfx.CopyFromScreen(0, 0, 0, 0, new Size(screenWidth, screenHeight));
    bmpScreenShot.Save("test.jpg", ImageFormat.Jpeg);

as I solve this problem?

Upvotes: 1

Views: 981

Answers (1)

AgentFire
AgentFire

Reputation: 9780

You need to draw the cursor on the image on your own. The system will not capture it since it is drawn in low-level driver.

To draw it at first you need to get cursor image itself from system's mouse settings as a cur file. Also you will need a current cursor type (hand, resize, etc) and its position at the moment of taking a screenshot.

Upvotes: 5

Related Questions