mouse pointer . . . again!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

is there a way to have the mouse pointer move from the form command button
you just clicked to some location on the screen (some X,Y coordinate) . just
so it is away from the form area itself is what is needed . . . any help
appreciated.
 
A little search of google came up with a couple of API's that worked ok for me:

In a general module:

Option Explicit
Public Type POINTAPI
x As Long
y As Long
End Type

Declare Function SetCursorPos Lib "User32" _
(ByVal x As Long, ByVal y As Long) As Long
Declare Function GetCursorPos Lib "User32" _
(lpPoint As POINTAPI) As Long


Behind the form:

Option Explicit
Private Sub CommandButton1_Click()
Dim myPointAPI As POINTAPI
GetCursorPos myPointAPI
Call SetCursorPos(myPointAPI.x - 300, myPointAPI.y)
End Sub

(I used 300 with my button, but you could experiment and use whatever you
needed.)
 
Back
Top