zoukankan      html  css  js  c++  java
  • c#截图

     截图

                Size screen = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
    
                Bitmap memoryImage = new Bitmap(screen.Width, screen.Height);
    
                Graphics memoryGraphics = Graphics.FromImage(memoryImage);
    
                memoryGraphics.CopyFromScreen(0, 0, 0, 0, screen, CopyPixelOperation.MergePaint);
                txtCc.Text = "yyyyMMddHHmmss";
                string jpg = DateTime.Now.ToString("yyyyMMddHHmmss") + ".jpg";
                memoryImage.Save(Environment.CurrentDirectory.ToString() + @"" + jpg, ImageFormat.Jpeg);
    
                UpdateXml("jpg", jpg);

    打开文件夹及关闭文件夹

      //打开文件夹
                //System.Diagnostics.Process.Start("explorer.exe", lblSelete.Text + @"");
                //Thread.Sleep(5000);         
                //截图
                //Thread.Sleep(5000);   
                //关闭所有文件夹
                //System.Diagnostics.Process[] myPs;
                //myPs = System.Diagnostics.Process.GetProcesses();
                //foreach (System.Diagnostics.Process p in myPs)
                //{
                //    if (p.ProcessName.ToLower() == "explorer".ToLower())
                //    {
                //        try
                //        {
                //            p.Kill();
                //        }
                //        catch (Exception ex)
                //        {
                //        }
                //    }
                //}

    其他

    //try
                //{
                //    label9.Text = label1.Text + "2";
                //    Bitmap image = new Bitmap(System.Windows.Forms.SystemInformation.VirtualScreen.Width, System.Windows.Forms.SystemInformation.VirtualScreen.Height);
                //    using (Graphics g = Graphics.FromImage(image))
                //    {
                //        label9.Text = label1.Text + "3";
                //        g.CopyFromScreen(0, 0, 0, 0, image.Size);
                //        g.Dispose();
                //        string hour = DateTime.Now.Minute.ToString();
                //        string second = DateTime.Now.Second.ToString();
                //        string jpgfile = Environment.CurrentDirectory.ToString() + @"" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".jpg";
                //        image.Save(jpgfile);
                //        UpdateXml("jpg", jpgfile);
                //        label9.Text = label1.Text + "4";
                //    }
                //}
                //catch (Exception  ex )
                //{
                //    label9.Text = label1.Text + ex;
    
                //}
                ////截取屏幕内容     
                //Graphics gSrc = this.CreateGraphics();    //创建窗体的Graphics对象 
                //HandleRef hDcSrc = new HandleRef(null, gSrc.GetHdc());
    
                //int width = System.Windows.Forms.SystemInformation.VirtualScreen.Width;    //获取宽度 
                //int height = System.Windows.Forms.SystemInformation.VirtualScreen.Height;    //获取高度 
    
                //const int SRCCOPY = 0xcc0020;    //复制图块的光栅操作码 
    
                //Bitmap bmSave = new Bitmap(width, height);    //用于保存图片的位图对象 
                //Graphics gSave = Graphics.FromImage(bmSave);    //创建该位图的Graphics对象 
                //HandleRef hDcSave = new HandleRef(null, gSave.GetHdc());    //得到句柄 
    
                //BitBlt(hDcSave, 0, 0, width, height, hDcSrc, 0, 0, SRCCOPY);
    
                //gSrc.ReleaseHdc();
                //gSave.ReleaseHdc();
    
                //gSrc.Dispose();
                //gSave.Dispose();
                //string jpgfile = Environment.CurrentDirectory.ToString() + @"" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".jpg";
                //Save(bmSave, jpgfile);           
                //UpdateXml("jpg", jpgfile);
  • 相关阅读:
    设置QtCreator多核编译
    ZeroMQ研究与应用分析及学习资料
    彻底卸载Visual Studio 2013、Visual Studio 2015
    delphi 动态设置和访问cxgrid列的Properties
    delphi 拷贝文件时有进度显示
    Delphi 连接mysql的功能,去除乱码, 需要设置字符集
    cxGrid1 的使用方法
    Django day12 分页器
    Django day11(一) ajax 文件上传 提交json格式数据
    Django day08 多表操作 (五) 常用和非常用用字段
  • 原文地址:https://www.cnblogs.com/bit-by-bit/p/6931959.html
Copyright © 2011-2022 走看看