C#中使用GetCursorPos获取屏幕坐标
2013-07-10 15:43
405 查看
[StructLayout(LayoutKind.Sequential)] public struct POINT { public int X; public int Y; public POINT(int x, int y) { this.X = x; this.Y = y; } public override string ToString() { return ("X:" + X + ", Y:" + Y); } } [DllImport("user32.dll", CharSet = CharSet.Auto)] public static extern bool GetCursorPos(out POINT pt);
使用:
POINT currentPosition = new POINT(); GetCursorPos(out currentPosition); System.Diagnostics.Debug.WriteLine("Current mouse point: " + currentPosition.ToString());
//转为客户区域坐标 Point relativePos = itemsControl.PointFromScreen(new Point(currentPosition.X, currentPosition.Y));本文出自 “木子纵横” 博客,请务必保留此出处http://muzizongheng.blog.51cto.com/856912/1333020
相关文章推荐
- C#中使用GetCursorPos获取屏幕坐标
- C#中使用GetCursorPos获取屏幕坐标
- WPF 定时器DispatcherTimer+GetCursorPos 的使用,动态查看屏幕上任一点坐标
- WPF 定时器DispatcherTimer+GetCursorPos 的使用,动态查看屏幕上任一点坐标
- C# .NET中如何使用GetCursorPos函数
- GetCursorPos获取鼠标坐标
- 易语言GetMessagePos函数用法获取上次鼠标消息坐标
- 【c#】 使用Directory.GetFiles获取局域网中任意电脑指定文件夹下的文件
- c# 使用GetOleDbSchemaTable获取access数据库结构
- GetClinetRect GetWindowRect ScreenToClient ClientToScreen GetCursorPos几个函数的正确使用
- 获取坐标封装 getPos
- c#获取屏幕上某坐标点的颜色
- C#使用GET、POST请求获取结果
- C# 使用GET、POST请求获取结果
- 关于使用getDrawingCache()方法获取屏幕截图的问题
- 易语言-API 取窗口或者组件句柄的 屏幕坐标并限制区域 GetWindowRect ClipCursor getwindowrect GetClientRect WindowFromPoint
- 使用int rotation = mActivity.getWindowManager().getDefaultDisplay().getRotation();可以获取屏幕旋转的方向
- c#.net使用WinAPI: GetComputerName - 获取计算机名称
- C#使用GET、POST请求获取结果
- OpenGL 获取当前屏幕坐标对应的三维坐标,使用很简单glu库中的一个函数