Results 1 to 10 of 10

Thread: Auto-clicker possible?

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2005
    Posts
    51

    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?

  2. #2
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    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:
    1. ' These are the declerations... Put these at the top of your form / module
    2. Private Declare Sub mouse_event Lib "user32.dll" ( _
    3.     ByVal dwFlags As Long, _
    4.     ByVal dx As Long, _
    5.     ByVal dy As Long, _
    6.     ByVal cButtons As Long, _
    7.     ByVal dwExtraInfo As Long)
    8.  
    9. Private Const MOUSEEVENTF_LEFTDOWN = &H2
    10. Private Const MOUSEEVENTF_LEFTUP = &H4
    11. Private Const MOUSEEVENTF_MIDDLEDOWN = &H20
    12. Private Const MOUSEEVENTF_MIDDLEUP = &H40
    13. Private Const MOUSEEVENTF_MOVE = &H1
    14. Private Const MOUSEEVENTF_ABSOLUTE = &H8000
    15. Private Const MOUSEEVENTF_RIGHTDOWN = &H8
    16. Private Const MOUSEEVENTF_RIGHTUP = &H10

    And then isnide a timer who's interval is set to 1,000 put this:


    VB Code:
    1. ' This is the function call, simulate left mouse button click...
    2. ' For others see the other constants defined above.
    3. mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0&, 0&,


    Cheers,

    RyanJ
    My Blog.

    Ryan Jones.

  3. #3
    Old Member moeur's Avatar
    Join Date
    Nov 2004
    Location
    Wait'n for Free Stuff
    Posts
    2,712

    Re: Auto-clicker possible?

    It doesn't have to be just in your own form

  4. #4
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    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
    My Blog.

    Ryan Jones.

  5. #5

    Thread Starter
    Member
    Join Date
    Apr 2005
    Posts
    51

    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:
    1. ' These are the declerations... Put these at the top of your form / module
    2. Private Declare Sub mouse_event Lib "user32.dll" ( _
    3.     ByVal dwFlags As Long, _
    4.     ByVal dx As Long, _
    5.     ByVal dy As Long, _
    6.     ByVal cButtons As Long, _
    7.     ByVal dwExtraInfo As Long)
    8.  
    9. Private Const MOUSEEVENTF_LEFTDOWN = &H2
    10. Private Const MOUSEEVENTF_LEFTUP = &H4
    11. Private Const MOUSEEVENTF_MIDDLEDOWN = &H20
    12. Private Const MOUSEEVENTF_MIDDLEUP = &H40
    13. Private Const MOUSEEVENTF_MOVE = &H1
    14. Private Const MOUSEEVENTF_ABSOLUTE = &H8000
    15. Private Const MOUSEEVENTF_RIGHTDOWN = &H8
    16. Private Const MOUSEEVENTF_RIGHTUP = &H10

    And then isnide a timer who's interval is set to 1,000 put this:


    VB Code:
    1. ' This is the function call, simulate left mouse button click...
    2. ' For others see the other constants defined above.
    3. 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:
    1. Private Declare Sub mouse_event Lib "user32.dll" ( _
    2.     ByVal dwFlags As Long, _
    3.     ByVal dx As Long, _
    4.     ByVal dy As Long, _
    5.     ByVal cButtons As Long, _
    6.     ByVal dwExtraInfo As Long)
    7.  
    8. Private Const MOUSEEVENTF_LEFTDOWN = &H2
    9. Private Const MOUSEEVENTF_LEFTUP = &H4
    10. Private Const MOUSEEVENTF_MIDDLEDOWN = &H20
    11. Private Const MOUSEEVENTF_MIDDLEUP = &H40
    12. Private Const MOUSEEVENTF_MOVE = &H1
    13. Private Const MOUSEEVENTF_ABSOLUTE = &H8000
    14. Private Const MOUSEEVENTF_RIGHTDOWN = &H8
    15. Private Const MOUSEEVENTF_RIGHTUP = &H10
    16.  
    17.  
    18. Private Sub Form_Load()
    19. Timer1.Enabled = True
    20. End Sub
    21.  
    22. Private Sub Timer1_Timer()
    23.  
    24.  
    25.  
    26. mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0&, 0&
    27. 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

  6. #6
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    Re: Auto-clicker possible?

    OOPs, sorry

    Replace this:

    VB Code:
    1. mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0&, 0&

    With this:

    VB Code:
    1. mouse_event MOUSEEVENTF_LEFTDOWN, 0&, 0&, 0&, 0&
    2. 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.
    My Blog.

    Ryan Jones.

  7. #7

    Thread Starter
    Member
    Join Date
    Apr 2005
    Posts
    51

    Re: Auto-clicker possible?

    Quote Originally Posted by sciguyryan
    OOPs, sorry

    Replace this:

    VB Code:
    1. mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP, 0&, 0&

    With this:

    VB Code:
    1. mouse_event MOUSEEVENTF_LEFTDOWN, 0&, 0&, 0&, 0&
    2. 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,

  8. #8
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    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
    My Blog.

    Ryan Jones.

  9. #9
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    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?

  10. #10
    Frenzied Member sciguyryan's Avatar
    Join Date
    Sep 2003
    Location
    Wales
    Posts
    1,763

    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:
    1. Form1.ScaleMve = vbPixels
    2. mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_ABSOLUTE, (Button1.Left + 2), (Button1.Top - 2), 0&, 0&
    3. mouse_event MOUSEEVENTF_LEFTUP, 0&, 0&, 0&, 0&
    4. Form1.ScaleMode = vbTwips


    (Should work)

    Cheers,

    RyanJ
    Last edited by sciguyryan; May 15th, 2005 at 07:03 PM.
    My Blog.

    Ryan Jones.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width