110,535
社区成员
发帖
与我相关
我的任务
分享
public void PrintScreen()
{
keybd_event((byte)0x2c, 0, 0, 0);//down
keybd_event((byte)0x2c, 0, 2, 0);//up
}
private Bitmap GetScreenImage()
{
Bitmap NewBitmap = null;
try
{
if (Clipboard.ContainsImage())
{
NewBitmap = (Bitmap)(Clipboard.GetImage().Clone());
}
return NewBitmap;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return null;
}
}
private void button10_Click(object sender, EventArgs e)
{
ThreadPool.QueueUserWorkItem(new WaitCallback((s) => {
while (true)
{
PrintScreen();
Bitmap map = GetScreenImage();
if (map != null)
{
string strFile = DateTime.Now.ToString("mmss") + ".bmp";
map.Save(@"D:\2\" + strFile, ImageFormat.Bmp);
}
Thread.Sleep(5000);
}
}));
}
ThreadStart threadStart = new ThreadStart(new Action(() =>
{
while (true)
{
PrintScreen();
Bitmap map = GetScreenImage();
if (map != null)
{
string strFile = DateTime.Now.ToString("mmss") + ".bmp";
map.Save(@"D:\2\" + strFile, ImageFormat.Bmp);
}
Thread.Sleep(5000);
}
}));
Thread thread = new Thread(threadStart);
thread.SetApartmentState(ApartmentState.STA);
//keybd_event((byte)0x2c, 0, 0, 0);//down
//keybd_event((byte)0x2c, 0, 2, 0);//up
//System.Threading.Thread.Sleep(10);
SendKeys.SendWait("{PRTSC}");
this.BackgroundImage = Clipboard.GetImage();