whats wrong with my code...

Posts 1–15 of 18 · Page 1 of 2
whats wrong with my code...
I am trying to make hotkey launch what is inside each textbox but all that comes back is the time
and date they clicked the button... "1:19am 12-29-12" please help me fix this freaking weird dont know what to do.
its a little late.. so i must not be seeing something.
Code:
Imports System****Public Class Booster
    Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
    Private Function GetAsyncKeyState(keys As Keys) As Boolean
        Throw New NotImplementedException
    End Function
    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs)
        Timer1.enabled = True
        Timer1.Interval = 1
        Timer2.Enabled = True
        Timer2.Interval = 1
    End Sub


    Private Sub AdvantiumTheme1_Click(sender As System.Object, e As System.EventArgs) Handles AdvantiumTheme1.Click


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


    Private Sub AdvantiumButton2_Click(sender As System.Object, e As System.EventArgs) Handles AdvantiumButton2.Click
        If Directory.Exists("\Program Files (x86)") Then
            Process.Start("run.bat")
        Else
            If Directory.Exists("\Program Files") Then
                Process.Start("run32.bat")
            End If
        End If
    End Sub


    Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
        Dim Hotkey1 As Boolean
        Hotkey1 = GetAsyncKeyState(Keys.F5)
        If Hotkey1 = True Then
            SendKeys.Send("{Enter}")
            SendKeys.Send(TextBox1.Text)
            SendKeys.Send("{Enter}")
        Else
            Dim Hotkey2 As Boolean
            Hotkey2 = GetAsyncKeyState(Keys.F6)
            If Hotkey2 = True Then
                SendKeys.Send("{Enter}")
                SendKeys.Send(TextBox2.Text)
                SendKeys.Send("{Enter}")
            End If
        End If
    End Sub
    Private Sub Timer2_Tick(sender As System.Object, e As System.EventArgs) Handles Timer2.Tick
        Dim Hotkey3 As Boolean
        Hotkey3 = GetAsyncKeyState(Keys.End)
        If Hotkey3 = True Then
            Close()
        End If
    End Sub
End Class
complex **** man, the world may never know.
<_< why did you post if you have no idea what is going on in the code?
Put an example of what you're writing in the textbox.

Also 2 timers isnt needed plus GetAsyncKeyState is a boolean in itself.
These arnt needed
Code:
Dim Hotkey1 As Boolean
Dim Hotkey2 As Boolean
Dim Hotkey3 As Boolean
This on one timer should work
Code:
            If GetAsyncKeyState(Keys.F5) Then
                SendKeys.Send("{Enter}")
                SendKeys.Send(TextBox1.Text)
                SendKeys.Send("{Enter}")
            End If

            If GetAsyncKeyState(Keys.F6) Then
                SendKeys.Send("{Enter}")
                SendKeys.Send(TextBox2.Text)
                SendKeys.Send("{Enter}")
            End If

            If GetAsyncKeyState(Keys.End) Then
                Close()
            End If

Code:
IIf(Directory.Exists("\Program Files (x86)"), Process.Start("run.bat"), Process.Start("run32.bat"))
Quote Originally Posted by Pingo View Post

Code:
IIf(Directory.Exists("\Program Files (x86)"), Process.Start("run.bat"), Process.Start("run32.bat"))
dude... your amazing. this is so much shorter.

it just has a short input for a game. /r for crossfire as an example is to reply
my code got really short because of you lol...
Code:
Imports System****
Public Class Booster
    Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs)
        Timer1.Enabled = True
        Timer1.Interval = 1
    End Sub
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Close()
    End Sub


    Private Sub AdvantiumButton2_Click(sender As System.Object, e As System.EventArgs) Handles AdvantiumButton2.Click
        IIf(Directory.Exists("\Program Files (x86)"), Process.Start("run.bat"), Process.Start("run32.bat"))
    End Sub


    Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
        If GetAsyncKeyState(Keys.F5) Then
            SendKeys.Send("{Enter}")
            SendKeys.Send(TextBox1.Text)
            SendKeys.Send("{Enter}")
        End If


        If GetAsyncKeyState(Keys.F6) Then
            SendKeys.Send("{Enter}")
            SendKeys.Send(TextBox2.Text)
            SendKeys.Send("{Enter}")
        End If


        If GetAsyncKeyState(Keys.End) Then
            Close()
        End If
    End Sub
End Class
I know what's going on in the code..you can't get Process.Start() and/or SendKeys.Send to work correctly. Hmm :/


"if you have no idea what is going on in the code" <---- so why did you comment on dude's injector from the other section ?? exactly.

^^btw, I originally tried to ask OP questions, instead of straight-up saying it wasn't legit..you forced my hand.

I see you post code that doesn't need to be posted
Code:
    Private Sub AdvantiumTheme1_Click(sender As System.Object, e As System.EventArgs) Handles AdvantiumTheme1.Click


    End Sub
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Close()
    End Sub
^^ this speaks volumes . Same with the IIF thing. Learn vb.net before trying to be m4jor h4xor OR ask better questions.
Quote Originally Posted by abuckau907 View Post
I know what's going on in the code..you can't get Process.Start() and/or SendKeys.Send to work correctly. Hmm :/


"if you have no idea what is going on in the code" <---- so why did you comment on dude's injector from the other section ?? exactly.

^^btw, I originally tried to ask OP questions, instead of straight-up saying it wasn't legit..you forced my hand.

I see you post code that doesn't need to be posted
Code:
    Private Sub AdvantiumTheme1_Click(sender As System.Object, e As System.EventArgs) Handles AdvantiumTheme1.Click


    End Sub
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Close()
    End Sub
^^ this speaks volumes . Same with the IIF thing. Learn vb.net before trying to be m4jor h4xor OR ask better questions.
not a major hacker. just simple applications and I know it. please safe it for someone who cares.
btw: I clicked the background by accident and it launched it to the code producing that.
I can clean it up at the end and that is what i was planning to do before you stepped in.
same to you.

I have nothing against you being new -> it's because you comment (on the other post) had no purpose...
Quote Originally Posted by abuckau907 View Post
same to you.

I have nothing against you being new -> it's because you comment (on the other post) had no purpose...
Ok. i'm sorry. now leave me alone. i am trying to get some help.
Quote Originally Posted by AxiomFlux View Post
I am trying to make hotkey launch what is inside each textbox but all that comes back is the time
and date they clicked the button... "1:19am 12-29-12" please help me fix this freaking weird dont know what to do.
its a little late.. so i must not be seeing something.
Code:
Imports System****Public Class Booster
    Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
    Private Function GetAsyncKeyState(keys As Keys) As Boolean
        Throw New NotImplementedException
    End Function
    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs)
        Timer1.enabled = True
        Timer1.Interval = 1
        Timer2.Enabled = True
        Timer2.Interval = 1
    End Sub


    Private Sub AdvantiumTheme1_Click(sender As System.Object, e As System.EventArgs) Handles AdvantiumTheme1.Click


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


    Private Sub AdvantiumButton2_Click(sender As System.Object, e As System.EventArgs) Handles AdvantiumButton2.Click
        If Directory.Exists("\Program Files (x86)") Then
            Process.Start("run.bat")
        Else
            If Directory.Exists("\Program Files") Then
                Process.Start("run32.bat")
            End If
        End If
    End Sub


    Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
        Dim Hotkey1 As Boolean
        Hotkey1 = GetAsyncKeyState(Keys.F5)
        If Hotkey1 = True Then
            SendKeys.Send("{Enter}")
            SendKeys.Send(TextBox1.Text)
            SendKeys.Send("{Enter}")
        Else
            Dim Hotkey2 As Boolean
            Hotkey2 = GetAsyncKeyState(Keys.F6)
            If Hotkey2 = True Then
                SendKeys.Send("{Enter}")
                SendKeys.Send(TextBox2.Text)
                SendKeys.Send("{Enter}")
            End If
        End If
    End Sub
    Private Sub Timer2_Tick(sender As System.Object, e As System.EventArgs) Handles Timer2.Tick
        Dim Hotkey3 As Boolean
        Hotkey3 = GetAsyncKeyState(Keys.End)
        If Hotkey3 = True Then
            Close()
        End If
    End Sub
End Class
Code:
Private Declare Function GetAsyncKeyState Lib "user32" Alias "GetAsyncKeyState" (ByVal vkey As Long) As Integer    Private Function GetTime(ByVal _Event As String, ByVal _Starter As String, Optional ByVal _Enclose As Boolean = True, Optional ByVal _Chars As Integer = 0) As String 'Function to retun time // _Event can be used for what happened // _Starter if you want to use chars before time is displayed
        If _Enclose = True Then 'If you to enclose the time in characters
            Dim A() As String 'Declare an array
            Dim B As String 'Declare a string
            B = _Starter.Insert(_Chars, "&") 'Insert a character for us to split into an array 'A()'
            A = B.Split("&") 'Split
            GetTime = A(0) & My.Computer.Clock.LocalTime & A(1) & " - " & _Event 'Finally, returning (i.e - [TIME] - EVENT
        Else 'If _Enclose = false
            GetTime = _Starter & My.Computer.Clock.LocalTime & " - " & _Event 'Return (i.e - []- TIME - EVENT
            'Theres plenty of options for the time to be displayed as
        End If
    End Function


    Private Sub StartProgram(ByVal _ProgramPath As String)
        Shell(_ProgramPath, AppWinStyle.NormalFocus, True, 10000) 'Start a program, focused in windowed mode normal, waiting for program with 10sec timeout
    End Sub


    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        If GetAsyncKeyState(Keys.F5) Then 'If F5 is pressed
            StartProgram(TextBox1.Text) 'Starts whats inside textbox1
        End If
        If GetAsyncKeyState(Keys.F6) Then
            StartProgram(TextBox2.Text)
        End If
    End Sub
Example of usage:
Code:
MsgBox(GetTime("EVENT", "[]", True, 1)) 'Example of Usage
Quote Originally Posted by DawgiiStylz View Post


Code:
Private Declare Function GetAsyncKeyState Lib "user32" Alias "GetAsyncKeyState" (ByVal vkey As Long) As Integer    Private Function GetTime(ByVal _Event As String, ByVal _Starter As String, Optional ByVal _Enclose As Boolean = True, Optional ByVal _Chars As Integer = 0) As String 'Function to retun time // _Event can be used for what happened // _Starter if you want to use chars before time is displayed
        If _Enclose = True Then 'If you to enclose the time in characters
            Dim A() As String 'Declare an array
            Dim B As String 'Declare a string
            B = _Starter.Insert(_Chars, "&") 'Insert a character for us to split into an array 'A()'
            A = B.Split("&") 'Split
            GetTime = A(0) & My.Computer.Clock.LocalTime & A(1) & " - " & _Event 'Finally, returning (i.e - [TIME] - EVENT
        Else 'If _Enclose = false
            GetTime = _Starter & My.Computer.Clock.LocalTime & " - " & _Event 'Return (i.e - []- TIME - EVENT
            'Theres plenty of options for the time to be displayed as
        End If
    End Function


    Private Sub StartProgram(ByVal _ProgramPath As String)
        Shell(_ProgramPath, AppWinStyle.NormalFocus, True, 10000) 'Start a program, focused in windowed mode normal, waiting for program with 10sec timeout
    End Sub


    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        If GetAsyncKeyState(Keys.F5) Then 'If F5 is pressed
            StartProgram(TextBox1.Text) 'Starts whats inside textbox1
        End If
        If GetAsyncKeyState(Keys.F6) Then
            StartProgram(TextBox2.Text)
        End If
    End Sub
Example of usage:
Code:
MsgBox(GetTime("EVENT", "[]", True, 1)) 'Example of Usage
you got it all wrong. I just simply want the user to hit the hotkey and it type in something. kind of like an auto typer, but without doing it a thousand times. just once.
user= click f5 = sendkeys.send("{enter}" & textbox1.text & "{enter}")
it wont let me just do this...
Quote Originally Posted by AxiomFlux View Post
you got it all wrong. I just simply want the user to hit the hotkey and it type in something. kind of like an auto typer, but without doing it a thousand times. just once.
user= click f5 = sendkeys.send("{enter}" & textbox1.text & "{enter}")
it wont let me just do this...
Could use the form_KeyPressed event. Or something similar to that
If e.Keycode = Keycode.enter then
yada yada
End If

EDIT:
Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Keys.Enter Then
MsgBox("Yeh")
End If
End Sub
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer

vkey As Long > Need Continous ...

Change ;

Private Declare Function GetAsyncKeyState Lib "User32" (ByVal Key As Integer) As Integer
idk much about send keys, but try to do it in multiple lines, not all at 1 go.

Code:
sendkeys.send("{enter}" & textbox1.text & "{enter}")
it wont let me just do this...
so try...
Code:
SendKeys.SendWait("{enter}")
Sendkeys.SendWait(TextBox1.Text)
SendKeys.SendWait("{enter}")
maybe?

but -- if TextBox1 has any weird characters (other than aA-zZ,0-9, it might not work, but idk)
GetAsyncKeyState does not take a Long as an argument. That was for the OLD Visual Basic where Long was 4 bytes long. In VB.NET it is 8 bytes long. Also, the return type is not an Integer either, its a Short. You guys seriously need to look at MSDN or get proper declerations from a website like pinvoke.net:
Code:
<DllImport("user32.dll")> _
Public Shared Function GetAsyncKeyState(ByVal vKey As System.Windows.Forms.Keys) As Short
End Function
You shouldn't be implicitly converting the result from GetAsyncKeyState into a boolean because it returns flags about the key press. Use the 0x1 flag like this which acts like a toggle.

Code:
If (GetAsyncKeyState(Keys.F5) And &H1) = &H1 Then
Also, SendKeys will probably not work on CF.
Posts 1–15 of 18 · Page 1 of 2

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?