|
-
May 15th, 2005, 06:00 PM
#1
Thread Starter
Member
Auto-clicker possible?
Is there a piece of coding that can be run in VB6 that acts as if the mouse has been clicked, but it hasn't.
For example when i run the code, the mouse click, but i haven't touched the mouse, hope that makes sense.
If it is possible then is it possible to run the every second or something?
Would be much appreciated for any information
Cheers
Flukey
ps. could this be done via API?
-
May 15th, 2005, 06:07 PM
#2
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
-
May 15th, 2005, 06:16 PM
#3
Re: Auto-clicker possible?
It doesn't have to be just in your own form
-
May 15th, 2005, 06:19 PM
#4
Re: Auto-clicker possible?
 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
-
May 15th, 2005, 06:22 PM
#5
Thread Starter
Member
Re: Auto-clicker possible?
 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
-
May 15th, 2005, 06:30 PM
#6
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
Last edited by sciguyryan; May 15th, 2005 at 06:36 PM.
-
May 15th, 2005, 06:37 PM
#7
Thread Starter
Member
Re: Auto-clicker possible?
 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,
-
May 15th, 2005, 06:45 PM
#8
Re: Auto-clicker possible?
 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
-
May 15th, 2005, 06:49 PM
#9
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?
-
May 15th, 2005, 06:56 PM
#10
Re: Auto-clicker possible?
 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
Last edited by sciguyryan; May 15th, 2005 at 07:03 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|