Move mouse to screen pixel (XY)

0

Hello everyone, I'm having a problem, well I've already got the mouse position in relation to form!

For this I used a form with the border NONE, maximized, and opacity 5% and when the user clicks on this form it closes!

To get the coordinate of the form I used the MouseMove event and did as below. To send to 2 textbox in another form.

Posição.PosX.Text = e.X & vbLf
Posição.PosY.Text = e.Y & vbLf

It sends in the following style for each TextBox, just the number: 0/0.

But I noticed that when I do the function to move the mouse up to this coordinate, it moves wrong. Good happens that it moves so many "x" / "y" from the position of the mouse. And that was not to happen, it was to move up to the SCREEN pixel.

If it is confusing, it moves as follows: it moves 200 and 300 from the cursor, it does not move to pixel 200 and 300 from the screen.

To move I used the following:

Cursor.Position = New Point(Cursor.Position.X - PosX.Text, Cursor.Position.Y - PosY.Text)

So summarizing:

The mouse is moved using your location, what I want is to move it using the pixels of the SCREEN.

I would also like to know if it is possible for it to always move the cursor to the specified location even with the background application.

I have seen some programs like this, and created in VB.NET but I do not have access to the source code. CAN BE IN VB NET OR C #.

If you're a bit confused, let me explain below.

    
asked by anonymous 21.04.2017 / 18:01

1 answer

0

It's kind of confusing, but apparently, do you want to set the mouse position based on some control? , so use the PointToScreen

Cursor.Position = textBox1.PointToScreen(Point.Empty);
    
23.04.2017 / 01:44