ALERT!
Click here to register with a few steps and explore all our cool stuff we have to offer!
Home
Upgrade
Credits
Help
Search
Awards
Achievements
 4132

VB.Net Detect Key Presses

by 1UP - 10-10-2016 - 11:34 PM
#1
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.
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
Reply

Users browsing: 1 Guest(s)