Re: SetCursorPos question
use :
Code:
System.Windows.Forms.Cursor.Position
Re: SetCursorPos question
thnx and how do you define the position? can you please give an example how to use the code.
thnx!
Re: SetCursorPos question
Cursor.Position gives you a point in screen coordinates. You can turn that into a point relative to a given control using PointToClient. To get the cursor position in Form coordinates, for example, you would use:
vb.net Code:
Dim p As Point = Windows.Forms.Cursor.Position
Dim formPosition As Point = Me.PointToClient(p)
Similarly, to get the position relative to PictureBox1 it would be PictureBox1.PointToClient(p).
You can do the reverse with PointToScreen. For example, to get point(200, 100) on the form in screen coordinates:
vb.net Code:
Dim screenPosition As Point = Me.PointToScreen(New Point(200, 100))
groet, BB
Re: SetCursorPos question
mm it doensn't work. I add a new button
and ad the code
Code:
Dim screenPosition As Point = Me.PointToScreen(New Point(10, 20))
Re: SetCursorPos question
Maybe I didn't read your original question well enough (although it was a bit hard to understand:ehh:)
If you want to move the mouse pointer to screen pixel (10, 20), you do this:
vb.net Code:
Cursor.Position = New Point(10, 20)
If you want to move the mouse pointer to point (-50, -50) of your Form client area, you can do this:
vb.net Code:
Cursor.Position = Me.PointToScreen(New Point(-50, -50))
As you can see, the point does not actually have to be on the form.
Normally there is no need to spell out System.Windows.Forms.Cursor.Position in full.
I hope this answers your question, BB