| 1234567891011121314151617181920212223242526272829303132333435 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Runtime.InteropServices;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- namespace GeekDesk.Util
- {
- class MouseUtil
- {
- [DllImport("user32.dll")]
- [return: MarshalAs(UnmanagedType.Bool)]
- internal static extern bool GetCursorPos(ref Win32Point pt);
- [StructLayout(LayoutKind.Sequential)]
- internal struct Win32Point
- {
- public Int32 X;
- public Int32 Y;
- };
- /// <summary>
- /// 获取鼠标坐标
- /// </summary>
- /// <returns></returns>
- public static Point GetMousePosition()
- {
- var w32Mouse = new Win32Point();
- GetCursorPos(ref w32Mouse);
- return new Point(w32Mouse.X, w32Mouse.Y);
- }
- }
- }
|