屏幕截屏
截屏并赋值给pictureBox1进行显示:
Bitmap bm = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
Graphics g = Graphics.FromImage(bm);
g.CopyFromScreen(0, 0, 0, 0, bm.Size);
pictureBox1.Image = bm;
如果想连续截屏以每秒3FPS效果可以这样做:
new Thread(() =>
{
while (true)
{
Bitmap bm = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
Screen.PrimaryScreen.Bounds.Height);
Graphics g = Graphics.FromImage(bm);
g.CopyFromScreen(0, 0, 0, 0, bm.Size);
pictureBox1.Image = bm;
Thread.Sleep(1000 / 3);
}
}).Start();
效果图:

录制屏幕到视频文件
https://stackoverflow.com/questions/4068414/how-to-capture-screen-to-be-video-using-c-sharp-net
网友评论