Timed Recurring Key Press

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mcgrath50
    New Member
    • Dec 2006
    • 7

    #1

    Timed Recurring Key Press

    I am looking at writing a program that presses a key ('A') every minute in whatever the focused window is. I am having trouble working out what command to use in the timer1_timer sub so that it presses A and then restarts the timer, what I have at the moment dosn't work. I am using Visual Basic 2005 Express

    Here is the code

    Code:
    Public Class Form1
        'timer enabled on click of start button
        Private Sub cmdStart_Click()
            Timer1.Enabled = True
        End Sub
        'timer stopped on click of end button
        Private Sub cmdEnd_Click()
            Timer1.Enabled = False
        End Sub
    
        'send keys is activated every time the timer event occurs
        'Restarts the timer
        Private Sub Timer1_Timer()
            SendKeys.Send("A")
            Timer1.Enabled = True
        End Sub
    
        Private Sub cmdStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdStart.Click
    
        End Sub
        'Creates buble tooltip on mouse hover
        Private Sub cmdStart_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdStart.MouseHover
            toolTip.SetToolTip(cmdStart, "Click here to start the timer")
        End Sub
        'Creates bubble tooltip on mouse hover
        Private Sub cmdEnd_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdEnd.MouseHover
            toolTip.SetToolTip(cmdEnd, "Click here to stop the timer")
        End Sub
       End Class
  • willakawill
    Top Contributor
    • Oct 2006
    • 1646

    #2
    Originally posted by mcgrath50
    I am looking at writing a program that presses a key ('A') every minute in whatever the focused window is. I am having trouble working out what command to use in the timer1_timer sub so that it presses A and then restarts the timer, what I have at the moment dosn't work. I am using Visual Basic 2005 Express

    Here is the code

    Code:
    Public Class Form1
        'timer enabled on click of start button
        Private Sub cmdStart_Click()
            Timer1.Enabled = True
        End Sub
        'timer stopped on click of end button
        Private Sub cmdEnd_Click()
            Timer1.Enabled = False
        End Sub
    
        'send keys is activated every time the timer event occurs
        'Restarts the timer
        Private Sub Timer1_Timer()
            SendKeys.Send("A")
            Timer1.Enabled = True
        End Sub
    
        Private Sub cmdStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdStart.Click
    
        End Sub
        'Creates buble tooltip on mouse hover
        Private Sub cmdStart_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdStart.MouseHover
            toolTip.SetToolTip(cmdStart, "Click here to start the timer")
        End Sub
        'Creates bubble tooltip on mouse hover
        Private Sub cmdEnd_MouseHover(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdEnd.MouseHover
            toolTip.SetToolTip(cmdEnd, "Click here to stop the timer")
        End Sub
       End Class
    Hi. You are mixing your compilers :)
    vb6 and vb2005 are different beasts. vb2005 is .NET

    You have 2 cmdStart_Click event handlers in your code. In .NET you will need to go with the flow. Select the control name at the top left of the IDE and select the event handler at the top right. Let .NET do the work.

    Comment

    • mcgrath50
      New Member
      • Dec 2006
      • 7

      #3
      I never realised, would explain why thing where different, I just though it was an updated version of VB since i last used it!! ill post in the .NET forums, thanks

      Comment

      Working...