I cannot access Position of the cursor (move mouse programatically)

前端 未结 3 856
花落未央
花落未央 2021-01-25 16:34

this is my code:

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


        
相关标签:
3条回答
  • 2021-01-25 17:04

    You probably found your answer already or figured out a workaround, but since I had this same issue I thought I'd post what I discovered.

    The error popped up for me when I added a reference to System.Windows.Forms.DataVisualization.Charting. It seems that the way the cursor works with that reference is different from usual, and overrides the typical Cursor.Position.

    In my case, it was as simple as replacing "Cursor.Position" with "MousePosition".

    0 讨论(0)
  • 2021-01-25 17:04

    I found out what the issue was, Kinect does not send the parameters of the screen from 0 to display width, and it also has a - in the left part of the body, and + in the right, so I had to make a function to calculate the corect point to move the mouse to.

    0 讨论(0)
  • 2021-01-25 17:12

    I suggest you this code

    var pc = new PointConverter();
    var pt = new Point();
    pt = (Point)pc.ConvertFromString(string.Format("{0}, {1}",x,y));
    cursorMouse.Position = pt;
    

    link : http://msdn.microsoft.com/en-us/library/system.drawing.pointconverter.aspx

    0 讨论(0)
提交回复
热议问题