Why is this wrong??

mikewarren
09-11-2003, 01:21 PM
Here is my code for a simple time delayed mouse clicking program:

Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Const MOUSEEVENTF_LEFTDOWN = &H2
Const MOUSEEVENTF_LEFTUP = &H4
Const MOUSEEVENTF_MIDDLEDOWN = &H20
Const MOUSEEVENTF_MIDDLEUP = &H40
Const MOUSEEVENTF_MOVE = &H1
Const MOUSEEVENTF_ABSOLUTE = &H8000
Const MOUSEEVENTF_RIGHTDOWN = &H8
Const MOUSEEVENTF_RIGHTUP = &H10


Private Sub Form_Activate()
Dim x As Integer
x = 5
Do
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0&, 0&, cButt, dwEI
DoEvents
Delay (x)

Loop
End Sub

Sub Delay(t As Integer)
Timer1.Interval = t * 1000
Timer1.Enabled = True
Do While Timer1.Enabled
DoEvents
Loop
End Sub

Private Sub Timer1_Timer()
Timer1.Enabled = False
End Sub

Can anyone tell me why its wrong because when i try to run it i get a 'Runtime 424' error

reboot
09-11-2003, 01:35 PM
What line do you get Object Required on?

mikewarren
09-11-2003, 01:48 PM
What line do you get Object Required on?
well it doesnt say (maybe it does but im a noob to this so i dont understand)

passel
09-11-2003, 01:53 PM
I don't know why people want to make these auto-clicking mouse
routines, but in anycase, I just copied the code here, and it worked
fine for me. I just made sure I positioned my mouse over something
that wouldn't do any harm when the event fired.

Since the form doesn't show (you have an endless loop in the Form
Activate Event), I just put the mouse over the "stop" symbol in the
IDE, and when the 5 seconds had elapsed, the mouse click fired, and
the program ended.

mikewarren
09-11-2003, 02:01 PM
now i know which line is the problem its this one:
Timer1.Interval = t * 1000

reboot
09-11-2003, 02:04 PM
What exactly is this for anyway?

passel
09-11-2003, 04:26 PM
now i know which line is the problem its this one:
Timer1.Interval = t * 1000
Well I assume you didn't put a timer on your form.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum