Results 1 to 8 of 8

Thread: buttonClicker

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2008
    Posts
    778

    buttonClicker

    Hello,
    I want to create a program for key pressing, but it doesn't work.
    The program should press "F1" key every second or as I set it.

    Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
    Do
    If CheckBox1.Checked = False Then
    Exit Do
    End If
    System.Windows.Forms.SendKeys.Send("{F1}")
    Loop
    End Sub

    Any Ideas? Please

  2. #2

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,420

    Re: buttonClicker

    try this:

    vb Code:
    1. Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
    2.      If CheckBox1.Checked = False Then
    3.         Timer1.Enabled = False
    4.      Else
    5.         Timer1.Enabled = True
    6.      End If
    7. End Sub
    8.  
    9. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    10.      SendKeys.Send("{F1}")
    11. End Sub

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2008
    Posts
    778

    Re: buttonClicker

    Yes poul you really did it right, I will only need to create a loop so it would get repeated
    Thank you :

  5. #5
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,420

    Re: buttonClicker

    why do you need a loop? once you enable the timer it'll keep ticking until you stop it

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2008
    Posts
    778

    Re: buttonClicker

    ok then it uses the interval does it ?

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Apr 2008
    Posts
    778

    Re: buttonClicker

    I need to control the times when the buttons clicks, sometime i will need two buttons to be clicked at different intervals

  8. #8
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,420

    Re: buttonClicker

    if you set the timer interval for 1000 milliseconds it'll click your button once every second. use 2 timers if you need different intervals for 2 seperate buttons

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