Hotkeys

Posts 1–11 of 11 · Page 1 of 1
Hotkeys
I wanted to add hotkeys to my program (f7 to start, f8 to stop)
the program is a tapper.

this is my code:
Code:
 
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer

Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
        Dim starthotkey As Boolean
        starthotkey = GetAsyncKeyState(Keys.F7)
        Dim stophotkey As Boolean
        stophotkey = GetAsyncKeyState(Keys.F8)
        If starthotkey = True Then
            If TextBox1.Text = "" Then
                Timer3.Stop()
                MsgBox("To Prevent Host Failure, Start the game first.")
                Timer4.Start()
            Else
                Shell("cmd.exe /c ipconfig/release")
                Button1.Text = "Connect (F8)"
            End If
        Else
            Timer4.Stop()
        End If
        If stophotkey = True Then
            Timer3.Stop()
            Shell("cmd.exe /c ipconfig/renew")
            Button1.Text = "Disconnect (F7)"
            Timer4.Start()
        Else
            Timer4.Stop()
        End If
    End Sub

    Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick
        Timer4.Stop()
        Timer3.Start()
    End Sub
I tried, and if i don't press anything, it already does what it has to do when i press f7.

Code:
starthotkey = GetAsyncKeyState(Keys.F7) And &H8000
Tried this?
No, i will, ty.
edit: Tried, doesn't work either, nothing changes.
Post your FULL source code.
Sure, sec:

Code:
Public Class Form1
    Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim WR As Process() = Process.GetProcessesByName("warrock")
        Dim GZ As Process() = Process.GetProcessesByName("gunz")
        Dim CA As Process() = Process.GetProcessesByName("engine")
        Dim CF As Process() = Process.GetProcessesByName("crossfire")
        Dim PB As Process() = Process.GetProcessesByName("pblackout")
        Dim M1 As Process() = Process.GetProcessesByName("iw3mp")
        Dim M2 As Process() = Process.GetProcessesByName("iw4mp")
        Dim BO As Process() = Process.GetProcessesByName("blackopsmp")
        If WR.Length = 1 Then
            TextBox1.Text = "WR"
            Timer2.Start()
            Timer1.Stop()
            Me.Label1.ForeColor = Color.LimeGreen
        ElseIf GZ.Length = 1 Then
            TextBox1.Text = "GZ"
            Timer2.Start()
            Timer1.Stop()
        ElseIf CA.Length = 1 Then
            TextBox1.Text = "CA"
            Timer2.Start()
            Timer1.Stop()
        ElseIf CF.Length = 1 Then
            TextBox1.Text = "CF"
            Timer2.Start()
            Timer1.Stop()
        ElseIf PB.Length = 1 Then
            TextBox1.Text = "PB"
            Timer2.Start()
            Timer1.Stop()
        ElseIf M1.Length = 1 Then
            TextBox1.Text = "M1"
            Timer2.Start()
            Timer1.Stop()
        ElseIf M2.Length = 1 Then
            TextBox1.Text = "M2"
            Timer2.Start()
            Timer1.Stop()
        ElseIf BO.Length = 1 Then
            TextBox1.Text = "BO"
            Timer2.Start()
            Timer1.Stop()
        Else
            TextBox1.Text = ""
            Timer2.Start()
        End If
    End Sub

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        Timer2.Stop()
        If TextBox2.Text = "date" Then
            If TextBox1.Text = "WR" Then
                Me.Label1.Text = "Currently: In-Game: WarRock"
                Me.Label1.ForeColor = Color.LimeGreen
                Me.ForeColor = Color.LimeGreen
                Me.Button1.ForeColor = Color.LimeGreen
                Me.Button1.FlatAppearance.BorderColor = Color.LimeGreen
                Me.Button1.FlatAppearance.MouseDownBackColor = Color.Green
                Me.Button1.FlatAppearance.MouseOverBackColor = Color.MediumSeaGreen
                Timer1.Start()
            ElseIf TextBox1.Text = "GZ" Then
                Me.Label1.Text = "Currently: In-Game: Gunz"
                Me.Label1.ForeColor = Color.LimeGreen
                Me.ForeColor = Color.LimeGreen
                Me.Button1.ForeColor = Color.LimeGreen
                Me.Button1.FlatAppearance.BorderColor = Color.LimeGreen
                Me.Button1.FlatAppearance.MouseDownBackColor = Color.Green
                Me.Button1.FlatAppearance.MouseOverBackColor = Color.MediumSeaGreen
                Timer1.Start()
            ElseIf TextBox1.Text = "CA" Then
                Me.Label1.Text = "Currently: In-Game: Combat Arms"
                Me.Label1.ForeColor = Color.LimeGreen
                Me.Button1.ForeColor = Color.LimeGreen
                Me.Button1.FlatAppearance.BorderColor = Color.LimeGreen
                Me.Button1.FlatAppearance.MouseDownBackColor = Color.Green
                Me.Button1.FlatAppearance.MouseOverBackColor = Color.MediumSeaGreen
                Timer1.Start()
            ElseIf TextBox1.Text = "CF" Then
                Me.Label1.Text = "Currently: In-Game: CrossFire"
                Me.Label1.ForeColor = Color.LimeGreen
                Me.ForeColor = Color.LimeGreen
                Me.Button1.ForeColor = Color.LimeGreen
                Me.Button1.FlatAppearance.BorderColor = Color.LimeGreen
                Me.Button1.FlatAppearance.MouseDownBackColor = Color.Green
                Me.Button1.FlatAppearance.MouseOverBackColor = Color.MediumSeaGreen
                Timer1.Start()
            ElseIf TextBox1.Text = "PB" Then
                Me.Label1.Text = "Currently: In-Game: Project Blackout"
                Me.Label1.ForeColor = Color.LimeGreen
                Me.ForeColor = Color.LimeGreen
                Me.Button1.ForeColor = Color.LimeGreen
                Me.Button1.FlatAppearance.BorderColor = Color.LimeGreen
                Me.Button1.FlatAppearance.MouseDownBackColor = Color.Green
                Me.Button1.FlatAppearance.MouseOverBackColor = Color.MediumSeaGreen
                Timer1.Start()
            ElseIf TextBox1.Text = "M1" Then
                Me.Label1.Text = "Currently: In-Game: Modern Warfare"
                Me.Label1.ForeColor = Color.LimeGreen
                Me.ForeColor = Color.LimeGreen
                Me.Button1.ForeColor = Color.LimeGreen
                Me.Button1.FlatAppearance.BorderColor = Color.LimeGreen
                Me.Button1.FlatAppearance.MouseDownBackColor = Color.Green
                Me.Button1.FlatAppearance.MouseOverBackColor = Color.MediumSeaGreen
                Timer1.Start()
            ElseIf TextBox1.Text = "M2" Then
                Me.Label1.Text = "Currently: In-Game: Modern Warfare 2"
                Me.Label1.ForeColor = Color.LimeGreen
                Me.ForeColor = Color.LimeGreen
                Me.Button1.ForeColor = Color.LimeGreen
                Me.Button1.FlatAppearance.BorderColor = Color.LimeGreen
                Me.Button1.FlatAppearance.MouseDownBackColor = Color.Green
                Me.Button1.FlatAppearance.MouseOverBackColor = Color.MediumSeaGreen
                Timer1.Start()
            ElseIf TextBox1.Text = "BO" Then
                Me.Label1.Text = "Currently: In-Game: Black Ops"
                Me.Label1.ForeColor = Color.LimeGreen
                Me.ForeColor = Color.LimeGreen
                Me.Button1.ForeColor = Color.LimeGreen
                Me.Button1.FlatAppearance.BorderColor = Color.LimeGreen
                Me.Button1.FlatAppearance.MouseDownBackColor = Color.Green
                Me.Button1.FlatAppearance.MouseOverBackColor = Color.MediumSeaGreen
                Timer1.Start()
            ElseIf TextBox1.Text = "" Then
                Me.Label1.Text = "Currently: Not in-game"
                Me.Label1.ForeColor = Color.Red
                Me.ForeColor = Color.Red
                Me.Button1.ForeColor = Color.Red
                Me.Button1.FlatAppearance.BorderColor = Color.Red
                Me.Button1.FlatAppearance.MouseDownBackColor = Color.Maroon
                Me.Button1.FlatAppearance.MouseOverBackColor = Color****syBrown
                Timer1.Start()
            End If
        Else
            If TextBox1.Text = "WR" Then
                Me.Label1.Text = "Currently: In-Game: WarRock" & "    (" & TimeString & ")"
                Me.Label1.ForeColor = Color.LimeGreen
                Me.ForeColor = Color.LimeGreen
                Me.Button1.ForeColor = Color.LimeGreen
                Me.Button1.FlatAppearance.BorderColor = Color.LimeGreen
                Me.Button1.FlatAppearance.MouseDownBackColor = Color.Green
                Me.Button1.FlatAppearance.MouseOverBackColor = Color.MediumSeaGreen
                Timer1.Start()
                TextBox2.Text = ""
            ElseIf TextBox1.Text = "GZ" Then
                Me.Label1.Text = "Currently: In-Game: Gunz" & "    (" & TimeString & ")"
                Me.Label1.ForeColor = Color.LimeGreen
                Me.ForeColor = Color.LimeGreen
                Me.Button1.ForeColor = Color.LimeGreen
                Me.Button1.FlatAppearance.BorderColor = Color.LimeGreen
                Me.Button1.FlatAppearance.MouseDownBackColor = Color.Green
                Me.Button1.FlatAppearance.MouseOverBackColor = Color.MediumSeaGreen
                Timer1.Start()
                TextBox2.Text = ""
            ElseIf TextBox1.Text = "CA" Then
                Me.Label1.Text = "Currently: In-Game: Combat Arms" & "    (" & TimeString & ")"
                Me.Label1.ForeColor = Color.LimeGreen
                Me.Button1.ForeColor = Color.LimeGreen
                Me.Button1.FlatAppearance.BorderColor = Color.LimeGreen
                Me.Button1.FlatAppearance.MouseDownBackColor = Color.Green
                Me.Button1.FlatAppearance.MouseOverBackColor = Color.MediumSeaGreen
                Timer1.Start()
                TextBox2.Text = ""
            ElseIf TextBox1.Text = "CF" Then
                Me.Label1.Text = "Currently: In-Game: CrossFire" & "    (" & TimeString & ")"
                Me.Label1.ForeColor = Color.LimeGreen
                Me.ForeColor = Color.LimeGreen
                Me.Button1.ForeColor = Color.LimeGreen
                Me.Button1.FlatAppearance.BorderColor = Color.LimeGreen
                Me.Button1.FlatAppearance.MouseDownBackColor = Color.Green
                Me.Button1.FlatAppearance.MouseOverBackColor = Color.MediumSeaGreen
                Timer1.Start()
                TextBox2.Text = ""
            ElseIf TextBox1.Text = "PB" Then
                Me.Label1.Text = "Currently: In-Game: Project Blackout" & "    (" & TimeString & ")"
                Me.Label1.ForeColor = Color.LimeGreen
                Me.ForeColor = Color.LimeGreen
                Me.Button1.ForeColor = Color.LimeGreen
                Me.Button1.FlatAppearance.BorderColor = Color.LimeGreen
                Me.Button1.FlatAppearance.MouseDownBackColor = Color.Green
                Me.Button1.FlatAppearance.MouseOverBackColor = Color.MediumSeaGreen
                Timer1.Start()
                TextBox2.Text = ""
            ElseIf TextBox1.Text = "M1" Then
                Me.Label1.Text = "Currently: In-Game: Modern Warfare" & "    (" & TimeString & ")"
                Me.Label1.ForeColor = Color.LimeGreen
                Me.ForeColor = Color.LimeGreen
                Me.Button1.ForeColor = Color.LimeGreen
                Me.Button1.FlatAppearance.BorderColor = Color.LimeGreen
                Me.Button1.FlatAppearance.MouseDownBackColor = Color.Green
                Me.Button1.FlatAppearance.MouseOverBackColor = Color.MediumSeaGreen
                Timer1.Start()
                TextBox2.Text = ""
            ElseIf TextBox1.Text = "M2" Then
                Me.Label1.Text = "Currently: In-Game: Modern Warfare 2" & "    (" & TimeString & ")"
                Me.Label1.ForeColor = Color.LimeGreen
                Me.ForeColor = Color.LimeGreen
                Me.Button1.ForeColor = Color.LimeGreen
                Me.Button1.FlatAppearance.BorderColor = Color.LimeGreen
                Me.Button1.FlatAppearance.MouseDownBackColor = Color.Green
                Me.Button1.FlatAppearance.MouseOverBackColor = Color.MediumSeaGreen
                Timer1.Start()
                TextBox2.Text = ""
            ElseIf TextBox1.Text = "BO" Then
                Me.Label1.Text = "Currently: In-Game: Black Ops" & "    (" & TimeString & ")"
                Me.Label1.ForeColor = Color.LimeGreen
                Me.ForeColor = Color.LimeGreen
                Me.Button1.ForeColor = Color.LimeGreen
                Me.Button1.FlatAppearance.BorderColor = Color.LimeGreen
                Me.Button1.FlatAppearance.MouseDownBackColor = Color.Green
                Me.Button1.FlatAppearance.MouseOverBackColor = Color.MediumSeaGreen
                Timer1.Start()
                TextBox2.Text = ""
            ElseIf TextBox1.Text = "" Then
                Me.Label1.Text = "Currently: Not in-game" & "    (" & TimeString & ")"
                Me.Label1.ForeColor = Color.Red
                Me.ForeColor = Color.Red
                Me.Button1.ForeColor = Color.Red
                Me.Button1.FlatAppearance.BorderColor = Color.Red
                Me.Button1.FlatAppearance.MouseDownBackColor = Color.Maroon
                Me.Button1.FlatAppearance.MouseOverBackColor = Color****syBrown
                Timer1.Start()
                TextBox2.Text = "Date"
            End If
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If Button1.Text = "Connect (F8)" Then
            Shell("cmd.exe /c ipconfig/renew")
            Button1.Text = "Disconnect (F7)"
        Else
            If TextBox1.Text = "" Then
                MsgBox("To Prevent Host Failure, Start the game first.")
            Else
                Shell("cmd.exe /c ipconfig/release")
                Button1.Text = "Connect (F8)"
            End If
        End If

    End Sub

   
    Private Sub Timer5_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer5.Tick
        Me.Text = "Leaf's Tapper  " & DateString & " / " & TimeString
    End Sub



    Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs)

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
        Dim starthotkey As Boolean
        starthotkey = GetAsyncKeyState(Keys.F7) And &H8000
        Dim stophotkey As Boolean
        stophotkey = GetAsyncKeyState(Keys.F8)
        If starthotkey = True Then
            If TextBox1.Text = "" Then
                Timer3.Stop()
                MsgBox("To Prevent Host Failure, Start the game first.")
                Timer4.Start()
            Else
                Shell("cmd.exe /c ipconfig/release")
                Button1.Text = "Connect (F8)"
            End If
        Else
            Timer4.Stop()
        End If
        If stophotkey = True Then
            Timer3.Stop()
            Shell("cmd.exe /c ipconfig/renew")
            Button1.Text = "Disconnect (F7)"
            Timer4.Start()
        Else
            Timer4.Stop()
        End If
    End Sub

    Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick
        Timer4.Stop()
        Timer3.Start()
    End Sub
End Class
[highlight=VB.Net]Public Class Form1

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Int32) As Int16

Private Gamelist As New List(Of Game)

Private Structure Game
Dim Name As String
Dim ProcessName As String
Dim Shortcut As String
End Structure

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
For i = 0 To Gamelist.Count - 1
With Gamelist(i)
Dim p() As Process = Process.GetProcessesByName(.ProcessName)
If p.Count <> 0 Then
TextBox1.Text = .Shortcut
Timer2.Start()
Timer1.Stop()
Return
End If
End With
Next

TextBox1.Text = ""
End Sub

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
If TextBox1.Text <> "" Then
For i = 0 To Gamelist.Count - 1
With Gamelist(i)
If .Shortcut = TextBox1.Text Then
Me.Label1.Text = String.Format("Currently: In-Game: {0} {1}", .Name, IIf(TextBox2.Text.ToLower = "date", String.Concat("(", TimeString, ")"), ""))
Me.Label1.ForeColor = Color.LimeGreen
Me.ForeColor = Color.LimeGreen
Me.Button1.ForeColor = Color.LimeGreen
Me.Button1.FlatAppearance.BorderColor = Color.LimeGreen
Me.Button1.FlatAppearance.MouseDownBackColor = Color.Green
Me.Button1.FlatAppearance.MouseOverBackColor = Color.MediumSeaGreen
End If
End With
Next
Timer1.Start()
Else
Me.Label1.Text = String.Format("Currently: Not in-game {0}", IIf(TextBox2.Text.ToLower = "date", String.Concat("(", TimeString, ")"), ""))
Me.Label1.ForeColor = Color.Red
Me.ForeColor = Color.Red
Me.Button1.ForeColor = Color.Red
Me.Button1.FlatAppearance.BorderColor = Color.Red
Me.Button1.FlatAppearance.MouseDownBackColor = Color.Maroon
Me.Button1.FlatAppearance.MouseOverBackColor = Color.SaddleBrown
Timer1.Start()
TextBox2.Text = "Date"
End If
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Then MsgBox("To Prevent Host Failure, Start the game first.") : Return

Select Case Button1.Text
Case "Connect (F8)"
Shell("cmd.exe /c ipconfig/renew")
Button1.Text = "Disconnect (F7)"
Case "Disconnect (F7)"
Shell("cmd.exe /c ipconfig/release")
Button1.Text = "Connect (F8)"
End Select
End Sub

Private Sub Timer5_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer5.Tick
Me.Text = "Leaf's Tapper " & DateString & " / " & TimeString
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Gamelist.Add(New Game With {.Name = "Warrock", .ProcessName = "warrock", .Shortcut = "WR"})
Gamelist.Add(New Game With {.Name = "Gunz", .ProcessName = "gunz", .Shortcut = "GZ"})
Gamelist.Add(New Game With {.Name = "Combat Arms", .ProcessName = "engine", .Shortcut = "CA"})
Gamelist.Add(New Game With {.Name = "Crossfire", .ProcessName = "crossfire", .Shortcut = "CF"})
Gamelist.Add(New Game With {.Name = "Project Blackout", .ProcessName = "pblackout", .Shortcut = "PB"})
Gamelist.Add(New Game With {.Name = "Modern Warfare", .ProcessName = "iw3mp", .Shortcut = "M1"})
Gamelist.Add(New Game With {.Name = "Modern Warfare 2", .ProcessName = "iw4mp", .Shortcut = "M2"})
Gamelist.Add(New Game With {.Name = "Black Ops", .ProcessName = "blackopsmp", .Shortcut = "BO"})
End Sub

Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
If GetAsyncKeyState(Keys.F7) Then
If TextBox1.Text = "" Then
MsgBox("To Prevent Host Failure, Start the game first.")
Else
Shell("cmd.exe /c ipconfig/release")
Button1.Text = "Connect (F8)"
End If
End If

If GetAsyncKeyState(Keys.F8) Then
If TextBox1.Text = "" Then
MsgBox("To Prevent Host Failure, Start the game first.")
Else
Shell("cmd.exe /c ipconfig/renew")
Button1.Text = "Disconnect (F7)"
End If
End If
End Sub
End Class[/highlight]

Didn't even debug but can you give that code a try?

You may have to change some timer startings...
Quote Originally Posted by Blubb1337 View Post
[highlight=VB.Net]Public Class Form1

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Int32) As Int16

Private Gamelist As New List(Of Game)

Private Structure Game
Dim Name As String
Dim ProcessName As String
Dim Shortcut As String
End Structure

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
For i = 0 To Gamelist.Count - 1
With Gamelist(i)
Dim p() As Process = Process.GetProcessesByName(.ProcessName)
If p.Count <> 0 Then
TextBox1.Text = .Shortcut
Timer2.Start()
Timer1.Stop()
Return
End If
End With
Next

TextBox1.Text = ""
End Sub

Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
If TextBox1.Text <> "" Then
For i = 0 To Gamelist.Count - 1
With Gamelist(i)
If .Shortcut = TextBox1.Text Then
Me.Label1.Text = String.Format("Currently: In-Game: {0} {1}", .Name, IIf(TextBox2.Text.ToLower = "date", String.Concat("(", TimeString, ")"), ""))
Me.Label1.ForeColor = Color.LimeGreen
Me.ForeColor = Color.LimeGreen
Me.Button1.ForeColor = Color.LimeGreen
Me.Button1.FlatAppearance.BorderColor = Color.LimeGreen
Me.Button1.FlatAppearance.MouseDownBackColor = Color.Green
Me.Button1.FlatAppearance.MouseOverBackColor = Color.MediumSeaGreen
End If
End With
Next
Timer1.Start()
Else
Me.Label1.Text = String.Format("Currently: Not in-game {0}", IIf(TextBox2.Text.ToLower = "date", String.Concat("(", TimeString, ")"), ""))
Me.Label1.ForeColor = Color.Red
Me.ForeColor = Color.Red
Me.Button1.ForeColor = Color.Red
Me.Button1.FlatAppearance.BorderColor = Color.Red
Me.Button1.FlatAppearance.MouseDownBackColor = Color.Maroon
Me.Button1.FlatAppearance.MouseOverBackColor = Color.SaddleBrown
Timer1.Start()
TextBox2.Text = "Date"
End If
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "" Then MsgBox("To Prevent Host Failure, Start the game first.") : Return

Select Case Button1.Text
Case "Connect (F8)"
Shell("cmd.exe /c ipconfig/renew")
Button1.Text = "Disconnect (F7)"
Case "Disconnect (F7)"
Shell("cmd.exe /c ipconfig/release")
Button1.Text = "Connect (F8)"
End Select
End Sub

Private Sub Timer5_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer5.Tick
Me.Text = "Leaf's Tapper " & DateString & " / " & TimeString
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Gamelist.Add(New Game With {.Name = "Warrock", .ProcessName = "warrock", .Shortcut = "WR"})
Gamelist.Add(New Game With {.Name = "Gunz", .ProcessName = "gunz", .Shortcut = "GZ"})
Gamelist.Add(New Game With {.Name = "Combat Arms", .ProcessName = "engine", .Shortcut = "CA"})
Gamelist.Add(New Game With {.Name = "Crossfire", .ProcessName = "crossfire", .Shortcut = "CF"})
Gamelist.Add(New Game With {.Name = "Project Blackout", .ProcessName = "pblackout", .Shortcut = "PB"})
Gamelist.Add(New Game With {.Name = "Modern Warfare", .ProcessName = "iw3mp", .Shortcut = "M1"})
Gamelist.Add(New Game With {.Name = "Modern Warfare 2", .ProcessName = "iw4mp", .Shortcut = "M2"})
Gamelist.Add(New Game With {.Name = "Black Ops", .ProcessName = "blackopsmp", .Shortcut = "BO"})
End Sub

Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
If GetAsyncKeyState(Keys.F7) Then
If TextBox1.Text = "" Then
MsgBox("To Prevent Host Failure, Start the game first.")
Else
Shell("cmd.exe /c ipconfig/release")
Button1.Text = "Connect (F8)"
End If
End If

If GetAsyncKeyState(Keys.F8) Then
If TextBox1.Text = "" Then
MsgBox("To Prevent Host Failure, Start the game first.")
Else
Shell("cmd.exe /c ipconfig/renew")
Button1.Text = "Disconnect (F7)"
End If
End If
End Sub
End Class[/highlight]

Didn't even debug but can you give that code a try?

You may have to change some timer startings...
Jesus.
VB has a fucking weird syntax...
I will, thanks so much! you will definately get a spot in my creds
Found your problem, your decleration for GetAsyncKeyState is incorrect. That's from VB6. Back then, Long was 4 bytes (32-bit) but now it is 8 bytes (64-bit). If you had your project set to .NET Framework 4 you should have gotten a P/Invoke error.

Seems that Blubb1337 already fixed that for you though. You don't need the 'And &H8000' thing.
Ok thanks anyways, now i've got another prob ;(
check the No Recoil thread please
&H8000 performs a bitshift to get the most significant bit of the resulting int16.

&H8000 = "1000000000000000" (binary)

if the most significant bit is set, the key is down.

Anyways, marked solved.
Posts 1–11 of 11 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us