Re: Auto-clicker possible?
Yes, it is, do you want to make it click on your form or something else?
If your form then you could try the following:
VB Code:
' These are the declerations... Put these at the top of your form / module
Private Declare Sub mouse_event Lib "user32.dll" ( _
ByVal dwFlags As Long, _
ByVal dx As Long, _
ByVal dy As Long, _
ByVal cButtons As Long, _
ByVal dwExtraInfo As Long)
Private Const MOUSEEVENTF_LEFTDOWN = &H2
Private Const MOUSEEVENTF_LEFTUP = &H4
Private Const MOUSEEVENTF_MIDDLEDOWN = &H20
Private Const MOUSEEVENTF_MIDDLEUP = &H40
Private Const MOUSEEVENTF_MOVE = &H1
Private Const MOUSEEVENTF_ABSOLUTE = &H8000
Private Const MOUSEEVENTF_RIGHTDOWN = &H8
Private Const MOUSEEVENTF_RIGHTUP = &H10
And then isnide a timer who's interval is set to 1,000 put this:
VB Code:
' This is the function call, simulate left mouse button click...
' For others see the other constants defined above.
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0&, 0&,
Cheers,
RyanJ
Re: Auto-clicker possible?
It doesn't have to be just in your own form
Re: Auto-clicker possible?
Quote:
Originally Posted by moeur
It doesn't have to be just in your own form
No, that one just clicks whatever is under the cursor at the time, I was thinking of doing it another way :)
Cheers,
RyanJ
Re: Auto-clicker possible?
Quote:
Originally Posted by sciguyryan
Yes, it is, do you want to make it click on your form or something else?
If your form then you could try the following:
VB Code:
' These are the declerations... Put these at the top of your form / module
Private Declare Sub mouse_event Lib "user32.dll" ( _
ByVal dwFlags As Long, _
ByVal dx As Long, _
ByVal dy As Long, _
ByVal cButtons As Long, _
ByVal dwExtraInfo As Long)
Private Const MOUSEEVENTF_LEFTDOWN = &H2
Private Const MOUSEEVENTF_LEFTUP = &H4
Private Const MOUSEEVENTF_MIDDLEDOWN = &H20
Private Const MOUSEEVENTF_MIDDLEUP = &H40
Private Const MOUSEEVENTF_MOVE = &H1
Private Const MOUSEEVENTF_ABSOLUTE = &H8000
Private Const MOUSEEVENTF_RIGHTDOWN = &H8
Private Const MOUSEEVENTF_RIGHTUP = &H10
And then isnide a timer who's interval is set to 1,000 put this:
VB Code:
' This is the function call, simulate left mouse button click...
' For others see the other constants defined above.
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0&, 0&,
Cheers,
RyanJ
Hi,
Thanks very much for your help.
I have this (thanks to you :) )
VB Code:
Private Declare Sub mouse_event Lib "user32.dll" ( _
ByVal dwFlags As Long, _
ByVal dx As Long, _
ByVal dy As Long, _
ByVal cButtons As Long, _
ByVal dwExtraInfo As Long)
Private Const MOUSEEVENTF_LEFTDOWN = &H2
Private Const MOUSEEVENTF_LEFTUP = &H4
Private Const MOUSEEVENTF_MIDDLEDOWN = &H20
Private Const MOUSEEVENTF_MIDDLEUP = &H40
Private Const MOUSEEVENTF_MOVE = &H1
Private Const MOUSEEVENTF_ABSOLUTE = &H8000
Private Const MOUSEEVENTF_RIGHTDOWN = &H8
Private Const MOUSEEVENTF_RIGHTUP = &H10
Private Sub Form_Load()
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0&, 0&
End Sub
I keep getting an argument not optional, in the timer1_timer event.
Why is this?
What i want it to do is, every 10 milliseconds, leftbutton goes down and then goes back up again, would it be possible for you to post the code for that, would be much appreciated.
Once again Thanks
Jamie :)
Re: Auto-clicker possible?
OOPs, sorry :)
Replace this:
VB Code:
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0&, 0&
With this:
VB Code:
mouse_event MOUSEEVENTF_LEFTDOWN, 0&, 0&, 0&, 0&
mouse_event MOUSEEVENTF_LEFTUP, 0&, 0&, 0&, 0&
And that should fix it.
Now, all you have to do is put that in the Timer_Timer event and then set its interval to 10 and it should be done :) Be warned, this could cause problems as the mouse will litrerlaly be clicking nearly all the time. (Every 100th of a second to be exact)
EDIT: Edited the code, just to be shure :)
Cheers,
RyanJ
Re: Auto-clicker possible?
Quote:
Originally Posted by sciguyryan
OOPs, sorry :)
Replace this:
VB Code:
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0&, 0&
With this:
VB Code:
mouse_event MOUSEEVENTF_LEFTDOWN, 0&, 0&, 0&, 0&
mouse_event MOUSEEVENTF_LEFTUP, 0&, 0&, 0&, 0&
And that should fix it.
Now, all you have to do is put that in the Timer_Timer event and then set its interval to 10 and it should be done :) Be warned, this could cause problems as the mouse will litrerlaly be clicking nearly all the time. (Every 100th of a second to be exact)
EDIT: Edited the code, just to be shure :)
RyanJ
Cheers!! that fixed it!! You are in fact a legend.
How would i do it so it clicks on in a specific area? and also what is the API for Space bar keydown and up. Cheers
Cheers,
Re: Auto-clicker possible?
Quote:
Originally Posted by flukey2005
Cheers!! that fixed it!! You are in fact a legend.
How would i do it so it clicks on in a specific area? and also what is the API for Space bar keydown and up. Cheers
Cheers,
Clicking in a specific area of the screen would you to set the second and third perameters of the function to the exact co-ordinates (In pixels to where you would want it to click)
And as for clicking with keys, that requires another API called keyb_event - Have a look there for more information on that API :)
Cheers,
RyanJ
Re: Auto-clicker possible?
I had a button on my form, and moved the cursor over it. Nothing happened, but when I moved the cursor to the upper right area of the form, the mouse clicked the exit button, and the form closed.
Any idea why it didn't click the button?
Re: Auto-clicker possible?
Quote:
Originally Posted by dglienna
I had a button on my form, and moved the cursor over it. Nothing happened, but when I moved the cursor to the upper right area of the form, the mouse clicked the exit button, and the form closed.
Any idea why it didn't click the button?
Yes, that is odd - it should click at the cursors current position as far as I am aware: http://www.mentalis.org/apilist/mouse_event.shtml
Well, there maybe one way to cheet:
VB Code:
Form1.ScaleMve = vbPixels
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_ABSOLUTE, (Button1.Left + 2), (Button1.Top - 2), 0&, 0&
mouse_event MOUSEEVENTF_LEFTUP, 0&, 0&, 0&, 0&
Form1.ScaleMode = vbTwips
(Should work)
Cheers,
RyanJ