zoukankan      html  css  js  c++  java
  • 屏幕截图

    private void cutScreen()

            {
                ini_init();
                try
                {
                    this.WindowState = FormWindowState.Minimized; //最小化当前窗口
                    Thread.Sleep(500);//延时2秒

                    if (Directory.Exists(mypath))  //判断目录是否存在,不存在就创建
                    { }
                    else
                    {
                        DirectoryInfo directoryInfo = new DirectoryInfo(mypath);
                        directoryInfo.Create();
                    }
                    //创建图片对象
                    Bitmap bmp2 = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
                    Graphics g2 = Graphics.FromImage(bmp2);  //创建画笔
                    g2.CopyFromScreen(new Point(0, 0), new Point(0, 0), bmp2.Size);//截屏
                    string time = DateTime.Now.ToString("yyyy-MM-dd HHmmssfff");//获得系统时间
                    //time = System.Text.RegularExpressions.Regex.Replace(time, @"[^0-9]+", "");//提取数字
                    string fileName = mypath +@""+ time + ".bmp"; //创建文件名
                    bmp2.Save(fileName); //保存为文件  ,注意格式是否正确.
                    bmp2.Dispose();//关闭对象
                    g2.Dispose();//关闭画笔
                    label1.Text = "截图成功";
                    Thread.Sleep(500);//延时2秒
                    this.WindowState = FormWindowState.Maximized; //最小化当前窗口
                    pictureBox1.Image = Image.FromFile(fileName);
                    if (autoexit == "1")
                    {
                        checkBox2.Checked = true;
                        Thread.Sleep(1000);
                        DialogResult dr = MessageBox.Show("是否退出", "结束截图", MessageBoxButtons.YesNoCancel);
                        if (dr == DialogResult.OK)
                        {
                            this.Dispose();
                        }

                    }
                   
                }
                catch (Exception cse)
                {
                    label1.Text = cse.ToString();
                }
               

     
            }

  • 相关阅读:
    Node.js获得SQL Server驱动及更好的Windows工具
    二进制文件存取示例(VB&VBA)
    AmigaOS 4.1 Update 6 发布
    树形数据编号重排的通用存储过程
    谷歌升级云数据库:更多的储存及更快的读取
    nginx+keepalive主从 双机热备 + 自动切换解决方案
    sql导出mysql
    非UNICODE字段修改为UNICODE字段的可行性分析
    ipset 6.16.1 发布,网络设置工具
    Puppy Linux 5.4 "Precise" 发布
  • 原文地址:https://www.cnblogs.com/clarklxr/p/8566201.html
Copyright © 2011-2022 走看看