hello,
i am wondering how to move the mouse with the click of a button,
or a timer. ive looked through the tutorials and i always
get errors whenever i try to put the declarations in. please help quickly, thanks
Printable View
hello,
i am wondering how to move the mouse with the click of a button,
or a timer. ive looked through the tutorials and i always
get errors whenever i try to put the declarations in. please help quickly, thanks
To move the mouse, use the SetCursorPos api function.
Code:Private Sub Command1_Click()
Dim t&
t& = SetCursorPos(500,300)
End Sub
ok,
it told me that the setcursorpos was undefined.
-thanks in advance
Oops, it would help if I gave you the api function along with it :rolleyes:.
Code:Declare Function SetCursorPos Lib "user32" (ByVal x _
As Long, ByVal y As Long) As Long
If you're using it in a Form, it should be
Otherwise, you must place it in a Module.Code:Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
thanks megatron,
i needed the private thing in front. but heres another question for you, how do make it move to keep the screen saver at bay?
Simply use a Timer to keep changing the cursor position.
Add the following to a form with a Timer.
Code:Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Private Sub Form_Load()
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
'Move the Cursor in random places
Randomize
SetCursorPos Int(Rnd * 200) + 1, Int(Rnd * 200) + 1
End Sub