Getting Active Window Coordinates and Height Width in C#

前端 未结 2 1719
醉话见心
醉话见心 2021-02-10 10:04

I just check in some of the posts here, but none were helpful to me.

The thing I am trying to do is to run a background process of Screen Capturing. Now I want a piece

2条回答
  •  孤街浪徒
    2021-02-10 10:22

        [DllImport("user32.dll")]
        private static extern bool SetProcessDPIAware();
        [DllImport("user32.dll")]
        static extern IntPtr GetForegroundWindow();
        [DllImport("user32.dll")]
        [return: MarshalAs(UnmanagedType.Bool)]
        static extern bool GetWindowRect(IntPtr hWnd, out Rectangle lpRect);
    
        static void Main()
        {
            SetProcessDPIAware();
            Rectangle t2;
            GetWindowRect(GetForegroundWindow(),out t2);
        }
    

提交回复
热议问题