Results 1 to 8 of 8

Thread: Simple program. Need help.

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2011
    Posts
    3

    Simple program. Need help.

    I want to make a simple program that will click certain keys on my keyboard at a certain interval. I have VB10. Could someone provide me with some code?

  2. #2
    Addicted Member Joshlad's Avatar
    Join Date
    May 2011
    Location
    England
    Posts
    160

    Re: Simple program. Need help.

    What Keys, what interval, any code inside the keys?

  3. #3
    Addicted Member Joshlad's Avatar
    Join Date
    May 2011
    Location
    England
    Posts
    160

    Re: Simple program. Need help.

    Okay i figured it out, which was fun, working out the errors(having the letter f wrote infinitely )

    You will need a timer1 and then just this code.
    Code:
    Public Class Form1
        Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            Timer1.Interval = 10000 '10 seconds
            My.Computer.Keyboard.SendKeys("f", True)
        End Sub
        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Timer1.Enabled = True
        End Sub
    End Class

  4. #4
    Addicted Member Joshlad's Avatar
    Join Date
    May 2011
    Location
    England
    Posts
    160

    Re: Simple program. Need help.

    IF you want it to write to any specific file use this
    Code:
    Dim ProcID As Integer
    ' Start the Calculator application, and store the process id.
    ProcID = Shell("CALC.EXE", AppWinStyle.NormalFocus)
    ' Activate the Calculator application.
    AppActivate(ProcID)
    ' Send the keystrokes to the Calculator application.
    found this at http://msdn.microsoft.com/en-us/library/ms127847.aspx

  5. #5
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,104

    Re: Simple program. Need help.

    Use a timer and send a different key on each click. That would be the way to get the interval in there. Look up SendKeys for the key presses....maybe. Actually, after reading what Joshlad suggested, it does occur to me that there could be multiple ways to read that question. I was thinking that your goal was to send keys presses to some other program, but that isn't necessarily the case. Perhaps a bit more description would be good.

    EDIT: Wow, I think I need to refresh my browser faster. You had it solved before I even started writing.
    My usual boring signature: Nothing

  6. #6

    Thread Starter
    New Member
    Join Date
    Oct 2011
    Posts
    3

    Re: Simple program. Need help.

    I just want the program to hit the keys 6 and 7 every 5 seconds. Thanks for all the assistance!

  7. #7
    Addicted Member Joshlad's Avatar
    Join Date
    May 2011
    Location
    England
    Posts
    160

    Re: Simple program. Need help.

    Code:
    Public Class Form1
        Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            Timer1.Interval = 5000 '5 seconds
            My.Computer.Keyboard.SendKeys("6", True)
            My.Computer.Keyboard.SendKeys("7", True)
        End Sub
        
        sub button_click 'you finish it
            Timer1.Enabled = True
        End Sub
    End Class
    use a button also to enable the timer, and begin keys
    Quote Originally Posted by Shaggy Hiker View Post
    EDIT: Wow, I think I need to refresh my browser faster. You had it solved before I even started writing.
    May not be able to provide code, but i sure can provide the logic
    AutoTyper Moves Mouse Cursor to Screen Position
    All my Projects contain flashy scrolling text

  8. #8

    Thread Starter
    New Member
    Join Date
    Oct 2011
    Posts
    3

    Re: Simple program. Need help.

    Okay thank you!

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