Adblock breaks this site

[REPOST] Basic Tutorial - AutoTyper

Discussion in 'Programming General' started by Govind, Feb 2, 2011.

  1. Govind

    Govind The One Musketeer
    Mudkips Highly Respected Retired Administrator

    Joined:
    Apr 22, 2005
    Posts:
    7,825
    Referrals:
    13
    Sythe Gold:
    23
    Prove it! Trole Tier 1 Prizebox Tortoise Penis Le Monkey UWotM8? Wait, do you not have an Archer rank? Potamus
    [REPOST] Basic Tutorial - AutoTyper

    Get your hands on the freely available Visual Basic 2010 Express Edition.
    If you have access to Microsoft DreamSpark, you can download Visual Studio 2010 Professional, which includes a better version of Visual Basic 2010, and various other languages.

    On the New Project screen, create a new Windows Forms Application and name it AutoTyper. Press OK and the project will be created for you; a blank form design pane will appear on your screen. On the bottom-right corner of the screen, you will notice the Properties section. Under the Appearance subheading, change the Text field to "Auto Typer" (or whatever you want). You'll notice that after you hit Enter, the window title in the design pane changes from "Form1" to "Auto Typer".
    [​IMG]

    Under the View menu, click Toolbox and the toolbox interface will pop up on the left side of the screen (click the thumbtack icon to fix the toolbox pane and realign the design pane correctly). Create two buttons and one text box, and, under the Components subsection, drag a Timer control onto the form (this will be invisible when you build your project into an executable). Lay them out however you want; this is the way I did it:
    [​IMG]

    Rename the Text on one button to Start, and the other to Stop; also change their Name (first field under Design subheading) properties to startBtn and stopBtn respectively. Change the Name of the text box to typeTxt. These renamings are not necessary; it's just good to get in the habit of using descriptive and meaningful names for variables and controls. For example, if you ditch your project and come back to it months later, you may not remember what "Button1" was for, but if it was named "startBtn", that would give you some idea. Also, rename the Name on the Timer control from Timer1 to sendTimer. Double click the Start button, and a code window will appear. We're done with the n00b design phase; this is the real programming part :)

    Code:
    Private Sub startBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles startBtn.Click
    
        End Sub
    Your cursor will automatically go between those two lines. This event is fired whenever the Start button is clicked.

    Add these lines between the Private Sub... and End Sub lines:
    Code:
    sendTimer.Enabled = True
    sendTimer.Interval = 2000
    Basically, what this does is enable the timer to fire its own event every 2000 milliseconds. We are about to program that timer event.

    Go back to the design screen and double click the Timer control below your form. The following procedure will automatically be created for you:

    Code:
     Private Sub sendTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles sendTimer.Tick
    
        End Sub
    Between these two lines, add the following lines:

    Code:
    SendKeys.Send(typeTxt.Text())
           SendKeys.Send("{enter}")
    NOTE: If you changed the name of the TextBox control to anything other than "typeTxt", use that for the first line instead of typeText!

    Basically, whenever the timer event occurs (every 2000 milliseconds), the contents of typeTxt will be sent as keystrokes to the target window, as will the Enter key.

    Now, the last part...

    Double click the Stop button, and add the following line in the newly-created procedure:

    Code:
     sendTimer.Enabled = False 
    The logic behind this application is pretty easy to understand. Take a moment and think about it.

    Challenge: make the Start and Stop buttons mutually exclusive - when the Timer is Enabled, the Start button will be Disabled (after all, it's meaningless when the timer is Enabled), and when the timer is not Enabled, the Stop button will be Disabled (after all, what's there to stop if there's no timer firing?)

    Yes, that's a pretty simple challenge, but this is intended for really new programmers.
     
  2. Call me Mike

    Call me Mike Forum Addict

    Joined:
    Jan 18, 2011
    Posts:
    379
    Referrals:
    0
    Sythe Gold:
    0
    [REPOST] Basic Tutorial - AutoTyper

    This is very nice. Very detailed as well. Plan to make one later today. :)

    Thanks!
     
  3. p4nage

    p4nage Smoke
    Banned

    Joined:
    Nov 3, 2007
    Posts:
    1,107
    Referrals:
    1
    Sythe Gold:
    0
    [REPOST] Basic Tutorial - AutoTyper

    Hey Nice Tut ;) this may be a stupid question but how do i test my auto talker out?
     
  4. Covey

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816
    [REPOST] Basic Tutorial - AutoTyper

    Nice tut, SMR but it's .NET ;)
     
  5. Govind

    Govind The One Musketeer
    Mudkips Highly Respected Retired Administrator

    Joined:
    Apr 22, 2005
    Posts:
    7,825
    Referrals:
    13
    Sythe Gold:
    23
    Prove it! Trole Tier 1 Prizebox Tortoise Penis Le Monkey UWotM8? Wait, do you not have an Archer rank? Potamus
    [REPOST] Basic Tutorial - AutoTyper

    Lol moved.
     
  6. p4nage

    p4nage Smoke
    Banned

    Joined:
    Nov 3, 2007
    Posts:
    1,107
    Referrals:
    1
    Sythe Gold:
    0
    [REPOST] Basic Tutorial - AutoTyper

    ok kl, because one day i would like to make my own bot :)
     
  7. Hariov

    Hariov Active Member
    Banned

    Joined:
    Feb 13, 2011
    Posts:
    168
    Referrals:
    1
    Sythe Gold:
    0
    [REPOST] Basic Tutorial - AutoTyper

    Might try this out soon lol.
     
  8. The Gold Shop

    The Gold Shop Forum Addict
    Banned

    Joined:
    Feb 27, 2011
    Posts:
    593
    Referrals:
    1
    Sythe Gold:
    8
    [REPOST] Basic Tutorial - AutoTyper

    thanx, making now
     
  9. flightservices

    flightservices Active Member

    Joined:
    Feb 12, 2011
    Posts:
    137
    Referrals:
    0
    Sythe Gold:
    0
    [REPOST] Basic Tutorial - AutoTyper

    Actually this is not a good way to make an autotyper becouse you need to have the window focused this way

    With the use of some API's you can make an autotyper while the window is not focused
     
  10. Govind

    Govind The One Musketeer
    Mudkips Highly Respected Retired Administrator

    Joined:
    Apr 22, 2005
    Posts:
    7,825
    Referrals:
    13
    Sythe Gold:
    23
    Prove it! Trole Tier 1 Prizebox Tortoise Penis Le Monkey UWotM8? Wait, do you not have an Archer rank? Potamus
    [REPOST] Basic Tutorial - AutoTyper

    This is a beginners tutorial.

    Why would I step into the Win32 API right now?
     
  11. 420tim

    420tim Newcomer

    Joined:
    May 8, 2007
    Posts:
    9
    Referrals:
    0
    Sythe Gold:
    0
    [REPOST] Basic Tutorial - AutoTyper

    i have to say this is a nice basic auto-talker tut, could have mentioned on how you make it send the enter key aswell but ya, anyways i have a client ive been workin on for awhile and i have an auto talker built into it.
    first off i dont know much about api's yet so of course im not using apis in mine, but would like to figure out how to use my auto talker with apis since my client has tab controls and i can only use the auto-talker i made in 1 screen at a time... so i would appreciate some tips on how to use apis to get this working better


    heres the codes to my auto typer

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

    On Error Resume Next
    SendKeys.Send(txtMessage.Text())
    On Error Resume Next
    SendKeys.Send("{Enter}")

    End Sub

    Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click

    Timer1.Interval = txtSpeed.Text

    Timer1.Start()

    End Sub

    Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click

    Timer1.Stop()

    End Sub
     
  12. Covey

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816
    [REPOST] Basic Tutorial - AutoTyper

    A few little problems with your code that i'll explain sub by sub.

    Code:
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    
            On Error Resume Next
            SendKeys.Send(txtMessage.Text())
            On Error Resume Next
            SendKeys.Send("{Enter}")
    
        End Sub
    
    On error resume next, is a poor man's error handling method. You should use the Try & Catch procedures. I won't explain in further detail as you won't need them.
    Your code there should never cause an error so you shouldn't need the on error resume next line. (You should also only ever have 1 per sub)
    Code:
        Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            SendKeys.Send(txtMessage.Text())
            SendKeys.Send("{Enter}")
        End Sub
    
    Next sub;
    Code:
        Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
    
            Timer1.Interval = txtSpeed.Text
    
            Timer1.Start()
    
        End Sub
    Unless you have taken the proactive action of only allowing users to type in numbers you leave yourself open for a type mis-match error. (ie. forcing a string into an integer)
    To circumnavigate this error use the Val() function:
    Code:
        Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
            Timer1.Interval = val(txtSpeed.Text)
            Timer1.Start()
        End Sub
    Next sub;
    Your last sub is fine ;)
    Your code should look like this:
    Code:
        Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
            SendKeys.Send(txtMessage.Text())
            SendKeys.Send("{Enter}")
        End Sub
    
        Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
            Timer1.Interval = val(txtSpeed.Text)
            Timer1.Start()
        End Sub
    
        Private Sub btnStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStop.Click
            Timer1.Stop()
        End Sub
     
< Selling Keylogger? | ReaverCoding >


 
 
Adblock breaks this site