View Full Version : Cursor auto position in textbox
Hey Guys,
How do I get my cusor to automaticaly go to a specific textbox when I load a form?
This worked for me:
Either set that textboxe's tabindex property to zero, or in the Form_Activate event code sub add TextBox1.SetFocus :)
If you want to mouse to "jump" to a label or text box etc. the here is the code to move the mouse
Option Explicit
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long
Private Declare Function SetCursorPos Lib "user32" (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 hwnd, pt
SetCursorPos pt.x, pt.y
End Sub
Private Sub Form_Load()
MoveMouse Target.Left + Target.Width / 2, _
Target.Top + Target.Height / 2
End Sub
My code moves the mouse to the middle of a circle shape called "Target".
vBulletin® v3.8.3, Copyright ©2000-2010, Jelsoft Enterprises Ltd.