Move mouse to screen pixel (XY)

Asked

Viewed 1,163 times

0

Hello guys I’m having a problem, well I already managed to get the mouse position in relation to form !

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

To get the coordinate of the form I used the event Mousemove 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, only the number: 0 / 0.

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

If you are confused it is as follows: it moves 200 and 300 of the cursor, does not move to the 200 and 300 pixel of the screen.

To move I used the following:

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

So to summarize:

The mouse is moved using its location, what I want is that it moves using the pixels of the SCREEN.

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

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 little confused, talk down and I’ll try to explain even better..

1 answer

0


is kind of confused the question, but apparently, you want to set the mouse position based on some control ?! therefore use Pointtoscreen

Cursor.Position = textBox1.PointToScreen(Point.Empty);
  • Opa I already got what I wanted like the mouse pointer was moved XY of itself was not moved to XY of the screen. But I removed Cursor.Position and it worked ;)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.