12
मैं बिटमैप में स्क्रीन को कैप्चर करने के लिए नीचे दिए गए कोड का उपयोग कर रहा हूं। स्क्रीन पर कब्जा कर लिया गया है, लेकिन मैं स्क्रीन पर माउस पॉइंटर प्राप्त करने में असमर्थ हूं। क्या आप कुछ वैकल्पिक दृष्टिकोण सुझा सकते हैं ताकि माउस भी कब्जा कर लिया जा सके?विंडोज एपीआई का उपयोग कर स्क्रीन और माउस पॉइंटर कैप्चर कैसे करें?
private Bitmap CaptureScreen()
{
// Size size is how big an area to capture
// pointOrigin is the upper left corner of the area to capture
int width = Screen.PrimaryScreen.Bounds.X + Screen.PrimaryScreen.Bounds.Width;
int height = Screen.PrimaryScreen.Bounds.Y + Screen.PrimaryScreen.Bounds.Height;
Size size = new Size(width, height);
Point pointOfOrigin = new Point(0, 0);
Bitmap bitmap = new Bitmap(size.Width, size.Height);
{
using (Graphics graphics = Graphics.FromImage(bitmap))
{
graphics.CopyFromScreen(pointOfOrigin, new Point(0, 0), size);
}
return bitmap;
}
}
, अच्छा स्वच्छ और तेजी से कोड। धन्यवाद। –
नोट, यह कोड कुछ कर्सर को गलत स्थिति में आकर्षित करेगा, क्योंकि आपको ऑफ़सेट के लिए 'GetIconInfo' कॉल करने की आवश्यकता है। इसके अलावा कुछ दिखाई देंगे, अधिक जानकारी के लिए: http://stackoverflow.com/questions/918990/ – WhoIsRich