using System;
using System.Collections.Generic;
using System.Text;

using System.Runtime.InteropServices;

namespace _SCREEN_CAPTURE
{
    /// <summary>
    /// 
    /// </summary>
    internal class Win32
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        [DllImport("user32.dll")]
        public static extern bool SetCursorPos(int x, int y);
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        [DllImport("user32.dll")]//获取桌面的句柄
        public static extern IntPtr GetDesktopWindow();
        /// <summary>
        /// 
        /// </summary>
        /// <param name="pHwnd"></param>
        /// <param name="pt"></param>
        /// <param name="uFlgs"></param>
        /// <returns></returns>
        [DllImport("user32.dll")]//在桌面找寻子窗体
        public static extern IntPtr ChildWindowFromPointEx(IntPtr pHwnd, LPPOINT pt, uint uFlgs);
        /// <summary>
        /// 
        /// </summary>
        public const int CWP_SKIPDISABLED = 0x2;   //忽略不可用窗体
        /// <summary>
        /// 
        /// </summary>
        public const int CWP_SKIPINVISIBL = 0x1;   //忽略隐藏的窗体
        /// <summary>
        /// 
        /// </summary>
        public const int CWP_All = 0x0;            //一个都不忽略
        /// <summary>
        /// 
        /// </summary>
        /// <param name="hWnd"></param>
        /// <param name="uMsg"></param>
        /// <param name="wParam"></param>
        /// <param name="lParam"></param>
        /// <returns></returns>
        [DllImport("user32.dll")]
        public static extern int SendMessage(IntPtr hWnd, uint uMsg, IntPtr wParam, IntPtr lParam);
        /// <summary>
        /// 
        /// </summary>
        public const uint WM_LBUTTONUP = 0x202;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="hWnd"></param>
        /// <param name="lpPoint"></param>
        /// <returns></returns>
        [DllImport("user32.dll")]//进行坐标转换 （再窗体内部进行查找）
        public static extern bool ScreenToClient(IntPtr hWnd, out LPPOINT lpPoint);
        /// <summary>
        /// 
        /// </summary>
        public struct LPPOINT
        {
            /// <summary>
            /// 
            /// </summary>
            public int X;
            /// <summary>
            /// 
            /// </summary>
            public int Y;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="hWnd"></param>
        /// <param name="lpRect"></param>
        /// <returns></returns>
        [DllImport("user32.dll")]//获得句柄对象的位置
        public static extern bool GetWindowRect(IntPtr hWnd, out LPRECT lpRect);
        /// <summary>
        /// 
        /// </summary>
        public struct LPRECT
        {
            /// <summary>
            /// 
            /// </summary>
            public int Left;
            /// <summary>
            /// 
            /// </summary>
            public int Top;
            /// <summary>
            /// 
            /// </summary>
            public int Right;
            /// <summary>
            /// 
            /// </summary>
            public int Bottom;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="pci"></param>
        /// <returns></returns>
        [DllImport("user32.dll")]
        public static extern bool GetCursorInfo(out PCURSORINFO pci);
        /// <summary>
        /// 
        /// </summary>
        public struct PCURSORINFO
        {
            /// <summary>
            /// 
            /// </summary>
            public int cbSize;
            /// <summary>
            /// 
            /// </summary>
            public int flag;
            /// <summary>
            /// 
            /// </summary>
            public IntPtr hCursor;
            /// <summary>
            /// 
            /// </summary>
            public LPPOINT ptScreenPos;
        }
    }
}
