Hi guyz,

I'm just wondering if it's possible to add the mouse when capturing the screen or monitor
in vb.net?

because I'm doing a project that would record the screen and I'm actually successfull doing that by capturing
the screen and include it in a timer, but my only problem is the mouse or the cursor isn't showing.

below is my sample code.

    Dim ScreenSize As Size = New Size(TotalScreenWitdh, MonitorHeightArray(0))
    Dim BMP As New Bitmap(TotalScreenWitdh, MonitorHeightArray(0))
    Dim GraphX As Graphics = FromImage(BMP)
    GraphX.CopyFromScreen(New Point(0, 0), New Point(0, 0), ScreenSize)

    Picturebox.Image = bmp

Thanks in advance.

Recommended Answers

All 5 Replies

Add this to your code right after the "CopyFromScreen".

      Cursor.Current.Draw(GraphX, New Rectangle(Point.Subtract(Cursor.Position, New Size(Cursor.Current.HotSpot.X, Cursor.Current.HotSpot.Y)), Cursor.Current.Size))

I hope that you are calling Dispose on GraphX when you are done with it.

Thanks for your post TnTin, I'll try your code later.. I hope It works.

n_n

Hi Tin,

I acctually tried the code you provide and it's working, the only problem I encounter is that every time the Timer calls the code for print screen my cursor blinks and I don't want that to happen. can you help me solve this problem?

Sorry for the late reply; I got distracted.
I have not experienced this blink issue. Can you post your project as a sip file, so that we can look it over. It may be an issue with your timer interval an/or your saving of the image.

Tin,

I tried running my application in a differenct computer and your mouse capture is working just fine, but when I try it in my computer the mouse still blinks. I think it's because the specs of my computer is low. that's why I don't reccommend using my application in a Pentium 4 computer. but all in all your code works like majic. Thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.