ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   mouse pointer . . . again! (https://www.excelbanter.com/excel-programming/337283-mouse-pointer-again.html)

lightbulb_bill[_2_]

mouse pointer . . . again!
 
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.

Dave Peterson

mouse pointer . . . again!
 
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.)

lightbulb_bill wrote:

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.


--

Dave Peterson


All times are GMT +1. The time now is 07:03 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com