我需要跟踪鼠标位置。虽然我尝试了几种方法来做到这一点,但如果鼠标位于另一台显示器上,我无法跟随/捕捉位置。Mutil监视器鼠标跟踪
[DllImport("user32.dll")]
public static extern bool GetCursorPos(ref Point pt);
[DllImport("user32.dll")]
public static extern bool GetCursorInfo(out CURSORINFO pci);
public void GetPosition(out int X, out int Y)
{
Point pt = new Point(0, 0);
X = Y = 0;
if (MouseMonitor.GetCursorPos(ref pt))
{
X = pt.X;
Y = pt.Y;
}
这个工程,但只在一个屏幕上。我也读过,我可能会尝试GetCursorInfo。我已经尝试过这一点,但总是会回来。 [DllImport(“user32.dll”)] public static extern bool GetCursorInfo(out CURSORINFO pci);
有什么建议吗?我的目标是追踪鼠标位置(在我自己的应用程序之外),无论它在哪个屏幕上。
非常感谢您的建议。 – Jeff 2011-05-23 17:41:45
此代码是否提供了改进?如果不是,你能否提供关于光标跟踪在另一台监视器上不起作用的更多具体信息? – 2011-05-23 19:32:29