VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Smart Move Mouse

by Warren Goff (20 Submissions)
Category: Miscellaneous
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (2 Votes)

I wanted to have the cursor to move to my focused command buttons to direct the action and be more user friendly. This little thing does the trick. I found it in some old code of mine but I think it was borrowed back then.

Rate Smart Move Mouse

Public Type POINTAPI
  X As Long
  Y As Long
End Type
Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Public Declare Function SetCursorPos Lib "user32.dll" (ByVal X As Long, ByVal Y As Long) As Long
Sub MoveMouse(X As Single, Y As Single)
Dim pt As POINTAPI
  pt.X = X
  pt.Y = Y
  ClientToScreen Form1.hwnd, pt
  SetCursorPos pt.X, pt.Y
End Sub
Private Sub Form_Activate()
  Command1.SetFocus
  MoveMouse 97, 72
End Sub

Download this snippet    Add to My Saved Code

Smart Move Mouse Comments

No comments have been posted about Smart Move Mouse. Why not be the first to post a comment about Smart Move Mouse.

Post your comment

Subject:
Message:
0/1000 characters