コード例 #1
0
        protected virtual void Update()
        {
            Cursor.visible = false;

            if (Input.GetKey(KeyCode.Mouse0))
            {
                focused = true;
            }

            if (focused)
            {
                SetCursorPos(0, 0);
                unsafe
                {
                    WinRect rect   = new WinRect();
                    var     window = GetActiveWindow();
                    GetWindowRect(window, new IntPtr(&rect));
                    SetCursorPos((rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2);
                }
            }

            // There *might* be an obvious lag of cursor.
            // Obvious in Editor but not obvious in build if hide the cursor.
            // Keep it stay. Keep it good.
            this.gameObject.transform.position = VirtualCursor.position;
        }
コード例 #2
0
        public static Rect UnityWindowPosition()
        {
            var process      = System.Diagnostics.Process.GetProcessesByName("Unity");
            var unitywinrect = new WinRect();

            GetWindowRect(process[0].MainWindowHandle, ref unitywinrect);
            return(new Rect(0, 0, 1900, 1600));
        }
コード例 #3
0
ファイル: Utils.cs プロジェクト: uta-gasp/let-me-out-desktop
    /**
     * <summary>Get the rectangle of either standalone game window (game running as .exe), or the game window in Unity editor</summary>
     * <returns>Game window rectangle</returns>
     * */
    public static Rect GetWindowRect()
    {
        WinRect rect     = new WinRect();
        IntPtr  gameHwnd = Application.isEditor ? GetUnityWindowHandle() : GetGameWindowHandle();

        GetWindowRect(gameHwnd, ref rect);
        return(new Rect(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top));
    }
コード例 #4
0
ファイル: Utils.cs プロジェクト: uta-gasp/let-me-out-desktop
    /**
     * <summary>Get the position of either standalone game window (game running as .exe), or the game window in Unity editor</summary>
     * <returns>Game window position</returns>
     * */
    public static Vector2 GetWindowPosition()
    {
        WinRect rect = new WinRect();

        GetWindowRect(GetUnityWindowHandle(), ref rect);

        return(new Vector2(rect.left, rect.top));
    }
コード例 #5
0
 private static MyRectInWin _unityWin;     // 当前Unity窗口的Rect(Windows坐标系)
 static MouseSimulater()
 {
     _temp       = new WinRect();
     _desktopWin = new MyRectInWin();
     _unityWin   = new MyRectInWin();
     RefreshWin();
     RefreshUnityWin();
     Cursor.visible = true;
 }
コード例 #6
0
 public void UpdateRect(WinRect winRect)
 {
     _left       = winRect.Left;
     _right      = winRect.Right;
     _bottom     = winRect.Bottom;
     _top        = winRect.Top;
     _weight     = _right - _left;
     _height     = _bottom - _top;
     _leftBottom = new Vector2(_left, _bottom);
 }
コード例 #7
0
ファイル: frmNewKey.cs プロジェクト: ProjectEGU/KeyReplace
 private void chkRegion_CheckedChanged(object sender, EventArgs e)
 {
     btnRegion.Enabled = chkRegion.Checked;
     if (chkRegion.Checked && WinRect != Rectangle.Empty)
     {
         txtMouseSubregion.Text = WinRect.ToString();
     }
     else
     {
         txtMouseSubregion.Text = "No subregion selected.";
     }
 }
コード例 #8
0
        //
        // Static methods
        //
        #region Static methods

        // Get desktop resolution
        public static ResolutionInfo GetResolution()
        {
            IntPtr desktop_hwnd = GetWindowRectWrapper.GetDesktopWindow();

            var desktop_rect = new WinRect();

            if (!GetWindowRectWrapper.GetWindowRectangle(desktop_hwnd, ref desktop_rect))
            {
                return(new ResolutionInfo());
            }
            else
            {
                return(new ResolutionInfo(desktop_rect));
            }
        }
コード例 #9
0
ファイル: frmNewKey.cs プロジェクト: ProjectEGU/KeyReplace
        private void btnRegion_Click(object sender, EventArgs e)
        {
            //mouse REGION
            DialogResult res;

            if (string.IsNullOrEmpty(cmbProcessMouse.Text.Trim()) || cmbProcessMouse.Text.Equals("<any>", StringComparison.OrdinalIgnoreCase))
            {
                res = wm.ShowDialog(null, WinRect);
            }
            else
            {
                res = wm.ShowDialog(cmbProcessMouse.Text.Split('|'), _clearOffset ? Rectangle.Empty : WinRect);
            }
            if (res == DialogResult.OK)
            {
                WinRect = wm.GetRect();
                txtMouseSubregion.Text = WinRect.ToString();
            }
            _clearOffset = false;
        }
コード例 #10
0
 private static extern bool GetWindowRect(IntPtr hwnd, out WinRect lpRect);
コード例 #11
0
 private static extern int DwmGetWindowAttribute(IntPtr hwnd, int dwAttribute, out WinRect pvAttribute, int cbAttribute);
コード例 #12
0
 public static extern bool GetWindowRect(IntPtr hwnd, out WinRect lpRect);
コード例 #13
0
ファイル: WinApi.cs プロジェクト: radtek/ScreenRuler
 internal static extern bool GetWindowRect(IntPtr hWnd, out WinRect lpRect);
コード例 #14
0
 private static extern bool GetWindowRect(IntPtr hWnd, ref WinRect winRect);  // 获取窗口的Rect
コード例 #15
0
ファイル: Utils.cs プロジェクト: uta-gasp/let-me-out-desktop
 private static extern bool GetWindowRect(IntPtr hwnd, ref WinRect rect);
コード例 #16
0
 public static extern bool GetWindowRect(System.IntPtr hwnd, ref WinRect rectangle);
コード例 #17
0
ファイル: BorderlessGrab.cs プロジェクト: enebe-nb/bhell
 [DllImport("user32.dll")] private static extern bool GetWindowRect(IntPtr hwnd, out WinRect lpRect);
コード例 #18
0
 // Constructor - From Windows RECT structure
 public ResolutionInfo(WinRect pRect)
 {
     mHeight = pRect.mBottom;
     mWidth  = pRect.mRight;
 }