コード例 #1
0
ファイル: WinApiHelper.cs プロジェクト: kig0047/ScreenAccess
            // private readonly ushort _dpi;

            public WindowInfo(ScreenCapture.User32.RECT rect) //, ushort dpi)
            {
                var height = rect.bottom - rect.top;
                var width  = rect.right - rect.left;

                this._offsetLimitX  = (ushort)(width / OffsetFraction);
                this._offsetLimitY  = (ushort)(height / OffsetFraction);
                this._windowCenterX = (ushort)(rect.left + width / 2);
                this._windowCenterY = (ushort)(rect.top + height / 2);
                //this._dpi = dpi;
            }
コード例 #2
0
ファイル: WinApiHelper.cs プロジェクト: kig0047/ScreenAccess
        public static bool IsCursorAtTheCenter()
        {
            var pos             = GetCursorPosition();
            var currentWindowId = GetForegroundWindow();

            if (!WindowsCache.TryGetValue(currentWindowId, out var windowInfo))
            {
                var windowRect = new ScreenCapture.User32.RECT();
                ScreenCapture.User32.GetWindowRect(currentWindowId, ref windowRect);
                windowInfo = new WindowInfo(windowRect); //, (ushort)DpiHelper.GetDpiForWindow(currentWindowId));
                WindowsCache.Add(currentWindowId, windowInfo);
            }

            return(windowInfo.IsCursorAtTheCenter(pos));
        }