mouse pointer . . . again!

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.
 
D

Dave Peterson

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.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top