我有两个问题:
1。如果按下某个键,我每隔1分钟如何截取屏幕截图例如
- 10:00: - >按键 - > Img1
- 10:01: - >按键 - > Img2
- 10:02: - >按键 - > IMG3
醇>
2。假设我的程序运行5-10分钟
,我该如何迭代图像链 string ImgPath = @"D:\"Img" + iteration + ".bmp";
Bitmap btmp = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
Graphics g = Graphics.FromImage(btmp);
g.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, btmp.Size, CopyPixelOperation.SourceCopy);
if(按任意键)
if(时差为1分钟)
btmp.Save(ImgPath,System.Drawing.Imaging.ImageFormat.Bmp);
此外,如果有更好的截屏方式,请在此处分享。
谢谢!
答案 0 :(得分:0)
您要做的是在拍照时开始(或重新启动)Stopwatch。然后,只要按下一个键,就会检查秒表是否已经运行了至少一分钟。如果有,则拍摄照片并重置秒表。总体思路:
private int _pictureNumber = 1;
如果要对图片进行编号,请保留每次更新的变量。程序启动时,您将其初始化:
_pictureNumber = pictureNumber + 1;
每当你拍照时,你都会增加它。也就是说,重置秒表后,只需执行以下操作:
searchBar.translatesAutoresizingMaskIntoConstraints = false
searchBar.leadingAnchor.constraint(equalTo: self.view.leadingAnchor, constant: 0.0).isActive = true
searchBar.trailingAnchor.constraint(equalTo: self.view.trailingAnchor, constant: 0.0).isActive = true
searchBar.topAnchor.constraint(equalTo:self.topLayoutGuide.bottomAnchor, constant: 0.0).isActive = true