This bit of code will allow you to detect key presses while the form is not the active window. I currently use this for macros and for my trainer programs for turning on cheats.
All you need to have is a timer on the form. You can either drag and drop one on the form or declare it in code and write the timer.Tick event.
In this example I check for 2 key presses.
All you need to have is a timer on the form. You can either drag and drop one on the form or declare it in code and write the timer.Tick event.
In this example I check for 2 key presses.
Code:
Dim altkey As Boolean
Dim Num_1 As Boolean
Dim Num_2 As Boolean
Dim Num_3 As Boolean
Private Sub tmr_Keys_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmr_Keys.Tick
altkey = GetAsyncKeyState(Keys.LMenu)
Num_1 = GetAsyncKeyState(Keys.NumPad1)
Num_2 = GetAsyncKeyState(Keys.NumPad2)
Num_3 = GetAsyncKeyState(Keys.NumPad3)
If altkey And Num_1 = True Then 'Infinite Health Player 1
btn_P1InfiniteHealth_Click(sender, e)
ElseIf altkey And Num_2 = True Then
btn_P1InfiniteKi_Click(sender, e) ' Infinite Ki Player 1
ElseIf altkey And Num_3 = True Then
End If
End Sub