Пример #1
0
        public static Size GetClientAreaSize(int processId)
        {
            Size    size    = new Size(1, 1);
            Process process = Process.GetProcessById(processId);

            if (process == null)
            {
                return(size);
            }
            var rect = new Win32Api.RECT();

            return(Win32Api.GetClientRect(process.MainWindowHandle, out rect) ?
                   new Size(rect.Right, rect.Bottom) : size);
        }
Пример #2
0
        public static Size GetWindowSize(int processId)
        {
            Size    size    = new Size();
            Process process = Process.GetProcessById(processId);

            if (process == null)
            {
                return(size);
            }
            var rect = new Win32Api.RECT();

            // Windows 10における1pxの枠を除去するため-2する
            return(Win32Api.DwmGetWindowAttribute(process.MainWindowHandle, Win32Api.DWMWA_EXTENDED_FRAME_BOUNDS, out rect, 16) == 0 ?
                   new Size(rect.Right - rect.Left - 2, rect.Bottom - rect.Top - 2) : size);
        }
Пример #3
0
        public static Point GetWindowPoint(int processId)
        {
            Point   point   = new Point();
            Process process = Process.GetProcessById(processId);

            if (process == null)
            {
                return(point);
            }
            var rect = new Win32Api.RECT();

            // Windows 10における1pxの枠を除去するため+1する
            return(Win32Api.DwmGetWindowAttribute(process.MainWindowHandle, Win32Api.DWMWA_EXTENDED_FRAME_BOUNDS, out rect, 16) == 0 ?
                   new Point(rect.Left + 1, rect.Top + 1) : point);
        }