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();
                }
               

     
            }

  • 相关阅读:
    Element-ui左侧菜单刷新依旧高亮显示当前菜单
    Element-ui表格单选
    Element-UI表格点击Popover 弹出框确定取消
    纯JS原生请求接口post方式
    Vue+Element-ui+二级联动封装组件
    Vue如何修改标题title呢?
    vue-cli3.0怎么修改端口?
    Element-ui上传文件(删除、添加、预览)
    关于Ubuntu的ifconfig命令出现SIOCSIFADDR系列错误
    关于keil 中出现“give arg types”
  • 原文地址:https://www.cnblogs.com/clarklxr/p/8566201.html
Copyright © 2011-2022 走看看