我无法访问光标位置(以编程方式移动鼠标)

2023-12-03

这是我的代码:

    private void MoveCursor(int x, int y)
    {
        // Set the Current cursor, move the cursor's Position,
        // and set its clipping rectangle to the form. 

        System.Windows.Forms.Cursor cursorMouse = new System.Windows.Forms.Cursor(System.Windows.Forms.Cursor.Current.Handle);
        cursorMouse.Position = new System.Drawing.Point(x, y);
        System.Windows.Forms.Cursor.Clip = new System.Drawing.Rectangle(cursorMouse.Position, cursorMouse.Size);
    }

我的控制台是这样说的:

 Error  11  Member 'System.Windows.Forms.Cursor.Position.get' cannot be accessed with an instance reference; qualify it with a type name instead    F:\Win8\Kinect\InterfaceController\celmaibun\KinectToolbox\KinectToolbox\GesturesViewer\MainWindow.xaml.cs  1314    13  NkGesturesViewer
 Error  12  Member 'System.Windows.Forms.Cursor.Position.get' cannot be accessed with an instance reference; qualify it with a type name instead    F:\Win8\Kinect\InterfaceController\celmaibun\KinectToolbox\KinectToolbox\GesturesViewer\MainWindow.xaml.cs  1315    77  NkGesturesViewer

现在,我是c#的初学者,我更习惯java和android。有朋友告诉我这和实例有关。但我不知道到底该怎么做。


您可能已经找到了答案或找到了解决方法,但由于我遇到了同样的问题,我想我应该发布我发现的内容。

当我添加对 System.Windows.Forms.DataVisualization.Charting 的引用时,出现了错误。光标与该引用的工作方式似乎与平常不同,并且覆盖了典型的 Cursor.Position。

就我而言,这就像用“MousePosition”替换“Cursor.Position”一样简单。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

我无法访问光标位置(以编程方式移动鼠标) 的相关文章

随机推荐