Post: VB.Net Detect Key Presses
08-20-2013, 10:32 PM #1
Default Avatar
Oneup
Guest
(adsbygoogle = window.adsbygoogle || []).push({}); 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.
    
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
Last edited by Oneup ; 08-21-2013 at 12:19 AM.

The following 2 users say thank you to Oneup for this useful post:

Pichu, ResistTheSun
09-02-2013, 07:15 PM #2
ResistTheSun
In Flames Much?
Ah that simple not sure on the uses this could have apart from the ones you posted. Thanks for posting it anywho.
09-04-2013, 06:32 AM #3
Default Avatar
Oneup
Guest
Originally posted by ResistTheSun View Post
Ah that simple not sure on the uses this could have apart from the ones you posted. Thanks for posting it anywho.


There were a few things I used this for. I used something like this as an application starter way back when before I discovered rocket dock. I also used it for some basic in game automation with a key press. But it just doenst work that well, hard to predict server lag.

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo