• 抓取屏幕带光标!


    [StructLayout(LayoutKind.Sequential)]
            struct POINT
            {
                public Int32 x;
                public Int32 y;
            }

            [StructLayout(LayoutKind.Sequential)]
            struct CURSORINFO
            {
                public Int32 cbSize;         // Specifies the size, in bytes, of the structure.
                // The caller must set this to Marshal.SizeOf(typeof(CURSORINFO)).
                public Int32 flags;         // Specifies the cursor state. This parameter can be one of the following values:
                //     0             The cursor is hidden.
                //     CURSOR_SHOWING     The cursor is showing.
                public IntPtr hCursor;           // Handle to the cursor.
                public POINT ptScreenPos;       // A POINT structure that receives the screen coordinates of the cursor.
            }

            [DllImport("user32.dll")]
            static extern bool GetCursorInfo(out CURSORINFO pci);

            private const Int32 CURSOR_SHOWING = 0x00000001;

    private void toCapture()
            {
                CURSORINFO pci;
                pci.cbSize = Marshal.SizeOf(typeof(CURSORINFO));
                GetCursorInfo(out pci);
                Cursor cur = new Cursor(pci.hCursor);

                Image img = new Bitmap(Screen.AllScreens[0].Bounds.Width, Screen.AllScreens[0].Bounds.Height);
                Graphics g = Graphics.FromImage(img);
                g.CopyFromScreen(new Point(0, 0), new Point(0, 0), Screen.AllScreens[0].Bounds.Size);           
                cur.Draw(g, new Rectangle(pci.ptScreenPos.x - 10, pci.ptScreenPos.y - 10, cur.Size.Width, cur.Size.Height));

                MemoryStream ms = new MemoryStream();
                img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                PBOX.Image = img;
                ms.Dispose();
                g.Dispose();
                //img.Dispose();
            }

  • 相关阅读:
    dubbo
    Executer invokeAll
    java并发编程实战 java并发编程的艺术 阅读随笔
    小程序如何获取指定类名高度
    一些好用的Swift三方框架
    微信小程序checkbox多选传多个参数的操作
    关于xcode出现An unknown error occurred. See the install log for more details安装失败解决办法
    iOS 针对于13.0和暗黑模式出现的适配问题
    iOS UITextField如何禁止输入表情及特殊字符
    判断iPhoneX适配问题
  • 原文地址:https://www.cnblogs.com/love2wllw/p/1739228.html
Copyright © 2020-2023  润新知