4 Replies - 594 Views - Last Post: 11 April 2013 - 05:03 PM Rate Topic: -----

#1 dueler  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 09-April 13

Help with Auto Typer Error? (VB2008)

Posted 09 April 2013 - 02:48 PM

So I've been mucking around in Visual Basic 2008 and made my first app which was an Auto Typer.
That quickly grew into a bunch of tools that i could add using many guides and examples.

So any way I've come across an error after trying to change my Auto Typer from 1 text box to 3.

The Auto Talker starts by sending a message box telling you that you have 2 seconds to move to the games text box.
It then sleeps for 2 seconds and then starts another Timer that sends the first line of text then moves on like so till it repeats the first timer.

It functions 99% correctly but there is a little glitch, The first time starting the auto typer will result as following.

Game Textbox:
Line 1 - Second 1
Line 2 - Second 1
Line 3 - Second 1
Line 1 - Second 2
Line 2 - Second 3
Line 3 - Second 4


And Repeat Seconds 2 to 4

Stoping and starting the auto typer will cause it to work properly starting from line1 moving up in lines in seconds as normal nomatter when you stopped it.

I'll post the relevant section of the code.

Public Class MultiAutoTyper

    <System.Runtime.InteropServices.DllImport("user32.dll")> _
    Private Shared Function GetAsyncKeyState(ByVal vkey As System.Windows.Forms.Keys) As Short
    End Function
    Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)
    Public Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal wMsg As Int32, ByVal wParam As Int32, ByVal s As String) As Int32

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        MsgBox("You will have 2 seconds to move your mouse to the textbox." & vbNewLine & "you can press press F10 at any time to stop the Auto Typer")
        Sleep(1000)
        ATTimer.Start()
        HotKeyFast.Start()

    End Sub

    Private Sub ATTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ATTimer.Tick

        If ("Line1Txt.Text.Length & Line2Txt.Text.Length & Line3Txt.Text.Length") = ("") Then
            Me.Visible = False
            Form2.Visible = True
            ATTimer.Enabled = False
        Else
            ATL1Timer.Start()
            ATTimer.Enabled = False
        End If

    End Sub

    Private Sub ATL1Timer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ATL1Timer.Tick

        If L1CB.Checked = False Then
            ATL1Timer.Interval = 1
            ATL1Timer.Enabled = False
            ATL2Timer.Enabled = True

        ElseIf L1CB.Checked = True Then
            ATL1Timer.Interval = WaitTimeTxt.Text * 1000
            SendKeys.Send(Line1Txt.Text)
            SendKeys.Send("{Enter}")
            ATL1Timer.Enabled = False
            ATL2Timer.Enabled = True
        End If
    End Sub

    Private Sub ATL2Timer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ATL2Timer.Tick

        If L2CB.Checked = False Then
            ATL2Timer.Interval = 1
            ATL2Timer.Enabled = False
            ATL3Timer.Enabled = True

        ElseIf L2CB.Checked = True Then
            ATL2Timer.Interval = WaitTimeTxt.Text * 1000
            SendKeys.Send(Line2Txt.Text)
            SendKeys.Send("{Enter}")
            ATL2Timer.Enabled = False
            ATL3Timer.Enabled = True
        End If
    End Sub

    Private Sub ATL3Timer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ATL3Timer.Tick

        If L3CB.Checked = False Then
            ATL3Timer.Interval = 1
            ATL3Timer.Enabled = False
            ATL1Timer.Enabled = True

        ElseIf L3CB.Checked = True Then
            ATL3Timer.Interval = WaitTimeTxt.Text * 1000
            SendKeys.Send(Line3Txt.Text)
            SendKeys.Send("{Enter}")
            ATL3Timer.Enabled = False
            ATL1Timer.Enabled = True
        End If

    End Sub



Like i said, its only the relevant parts but some help would be appreciated it's had me stumped for a few hours.

Is This A Good Question/Topic? 0
  • +

Replies To: Help with Auto Typer Error? (VB2008)

#2 IronRazer  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 343
  • View blog
  • Posts: 1,019
  • Joined: 01-February 13

Re: Help with Auto Typer Error? (VB2008)

Posted 09 April 2013 - 03:20 PM

Hi,
I am not sure if i understand the explanation of how it works but, i can see a problem in the following line If statement. If your trying to check if all three textboxes are empty then it should be like this
        If Line1Txt.Text.Length + Line2Txt.Text.Length + Line3Txt.Text.Length = 0 Then
            Me.Visible = False
            Form2.Visible = True
            ATTimer.Enabled = False
        Else
            ATL1Timer.Start()
            ATTimer.Enabled = False
        End If


Also these lines need the textbox text converted to an integer or a double before multiplying them by 1000.
        ATL1Timer.Interval = CInt(WaitTimeTxt.Text) * 1000
        OR
        ATL1Timer.Interval = CDbl(WaitTimeTxt.Text) * 1000


This should also be changed to use an Integer or UInteger
    Private Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Integer)


This post has been edited by IronRazer: 09 April 2013 - 03:34 PM

Was This Post Helpful? 0
  • +
  • -

#3 IronRazer  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 343
  • View blog
  • Posts: 1,019
  • Joined: 01-February 13

Re: Help with Auto Typer Error? (VB2008)

Posted 09 April 2013 - 03:49 PM

I also wanted to add that i am not sure if sleep is what you want or not. Sleep actually makes your program thread sleep for whatever time you set it for. It is different than a timer. With a timer your program is still able to operate while waiting for the 1 or 2 seconds. The Sleep causes the program to not function for 1 or 2 seconds. Here is a link to pinvoke site that has most of the API functions for VB.NET. pinvoke - Sleep API

If sleep is what you want then you could also use this instead of an API function.
        Threading.Thread.Sleep(1000) '1 second


This post has been edited by IronRazer: 09 April 2013 - 03:56 PM

Was This Post Helpful? 0
  • +
  • -

#4 lar3ry  Icon User is offline

  • Coding Geezer
  • member icon

Reputation: 310
  • View blog
  • Posts: 1,290
  • Joined: 12-September 12

Re: Help with Auto Typer Error? (VB2008)

Posted 09 April 2013 - 08:15 PM

Further to something IronRazer pointed out. The problem with this line:

 If ("Line1Txt.Text.Length & Line2Txt.Text.Length & Line3Txt.Text.Length") = ("") Then


is that you are concatenating string representations of three integers, and if your TextBoxes are empty, the result will be a string, specifically, "000", and not "", as you expect.

You can do yourself an enormous favor by placing an Option Strict On statement above the Class statement. See the link in my signature to see what this will do for you.
Was This Post Helpful? 1
  • +
  • -

#5 dueler  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 09-April 13

Re: Help with Auto Typer Error? (VB2008)

Posted 11 April 2013 - 05:03 PM

Thanks for the responses, i managed to get it working the main issue was the order of the code i had in each timer.
So i changed it to check for errors first and also fixed the line reading like was suggested that seemed to fix everything.

Tho i have a slight problem i cant figure out the logic to that i might ask help for.
No point me asking for help yet tho, gonna try figure it out on my own.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1