locked
Autoclick program RRS feed

  • Question

  • Hello!

    I want to create a simple autoclick program. What I want to to is a program that makes a click were the mouse cursor is at every 5 minutes (or at any defined period of time) for instance.

    I searched the web but I didnt find any examples.

    Thank you!

    Friday, July 29, 2011 8:53 AM

Answers

  • Assuming you're dealing around your form, because IMHO creating a program that clicks everywhere on the screen (that can be done using API like here) sounds a irritating experience for a computer user. So, if you'd like to click around your programmatically, create a MouseEventArgs and use a timer like this:

    See my answer here:

    http://social.msdn.microsoft.com/Forums/en/vbgeneral/thread/9d68ff70-41c8-4f65-8f32-77fe50ebd920

    For example click on every 5 minutes which means 300000 ms interval that is the value must be set as Timer's interval, then:

     Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            Dim arg As New MouseEventArgs(Windows.Forms.MouseButtons.Left, _
       1, Windows.Forms.Cursor.Position.X, Windows.Forms.Cursor.Position.Y, Nothing)
            Me.OnMouseClick(arg)
     End Sub

    ' See a proof (optional), move your cursor around (inside) your form WITHOUT clicking and wait till timer's click event fires:

     Private Sub Form1_click(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseClick
            Dim g As Graphics = Me.CreateGraphics
            g.DrawString("X", New Font("Arial", 20), Brushes.Black, e.Location.X, e.Location.Y)
    End Sub

    ..a X will be drawn programmatically which is caused by mouse-click simulation.

    HTH.



    Best regards, Saygılarımla, Onur Güzel

    Yazgeliştir Forumları VB.NET / C# Süper Moderatorü.

    Microsoft Haber Grupları Profilim (VB.NET)



    • Edited by Onur Güzel Friday, July 29, 2011 12:55 PM
    • Proposed as answer by Mike Feng Monday, August 1, 2011 10:29 AM
    • Marked as answer by Mike Feng Monday, August 8, 2011 12:57 PM
    Friday, July 29, 2011 12:47 PM

All replies