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

     
            }

  • 相关阅读:
    数据结构(一)线性表单链表试题
    虚拟研讨会:如何设计好的RESTful API?
    如何生成RestFul Api文档
    webstorm 10 设置文件的默认编码
    HAML学习
    Nodejs初阶之express
    RESTful API 简书
    解读Nodejs多核处理模块cluster
    Nginx做NodeJS应用负载均衡配置实例
    拿nodejs快速搭建简单Oauth认证和restful API server攻略
  • 原文地址:https://www.cnblogs.com/clarklxr/p/8566201.html
Copyright © 2011-2022 走看看