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);
  • 相关阅读:
    33.数组声明方式(var构造函数) 、检测数组类型、数组的属性(封装好的就一个length)、数组的方法
    31.this指向(写出调用链,找最近对象) this的默认绑定 隐式绑定 显示绑定(call(绑定对象) apply(绑定对象) 当括号内没放绑定对象的时候恢复默认绑定) bind
    31.
    30.函数作用域链 (GO AO 也叫词法作用域链)、 调用栈、调用栈涉及this绑定
    29.包装类(构造函数) 包装类作用及调用栈
    916. Word Subsets
    246. Strobogrammatic Number
    445. Add Two Numbers II
    2. Add Two Numbers
    341. Flatten Nested List Iterator
  • 原文地址:https://www.cnblogs.com/bit-by-bit/p/6931959.html
Copyright © 2011-2022 走看看