我正在尝试创建一个我可以打开并最小化的应用程序,或者只是将它留在那里,然后在热键的帮助下我希望它能够捕获屏幕的一部分,我得到了所有的覆盖并且工作正常,除了当我点击热键并打开游戏窗口时,不是截取游戏截图,而是截取该窗口下方的内容,我在各处搜索,无法找到答案,这是最接近的我得: c# screenshot of active window but doesn't caputre the window
这是我的代码:
Bitmap printscreen = new Bitmap(40, 20);
Graphics graphics = Graphics.FromImage(printscreen as Image);
graphics.CopyFromScreen(775, 515, 0, 0, printscreen.Size);
printscreen = Transform(printscreen);
Bitmap newImage = new Bitmap(100, 50);
using (Graphics gr = Graphics.FromImage(newImage))
{
gr.SmoothingMode = SmoothingMode.HighQuality;
gr.InterpolationMode = InterpolationMode.HighQualityBicubic;
gr.PixelOffsetMode = PixelOffsetMode.HighQuality;
gr.DrawImage(printscreen, new Rectangle(0, 0, 100, 50));
newImage.Save("code.jpg");
}
我想要实现的是捕获活动窗口或特定窗口的部分屏幕,谢谢!