Solved GetAsyncKeyState hotkeys [Turn on] + [Turn off]

Hexui Undetected CSGO Cheats Sinkicheat PUBG Cheat
Status
Not open for further replies.

ZxPwd

Newbie
Full Member
Jun 2, 2014
25
658
0
Hey everyone I don't have much to say other then I'm making a trainer in Vb.Net everything works perfect! except I'm fed up of using buttons
to turn on and off the hacks. I'm trying to use GetAsyncKeyState to use hotkeys but I only succeed in turning on the hack.

Is it possible for somebody too show me an example of turning on and turning off.
______________________________________________________________
EDITED:

Okay I will give you what I got so far.

Imports System
Imports System.IO
Imports System.Collections


Public Class Form1
#Region "Declarations"

Public Declare Function GetKeyPress Lib "user32" Alias "GetAsyncKeyState" (ByVal key As Integer) As Integer
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Integer) As Short

#End Region

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
hotkey.Start()
End Sub

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles hotkey.Tick
Dim hotkey1 As Boolean

hotkey1 = GetAsyncKeyState(Keys.NumPad1)
If hotkey1 = True Then
Label1.Text = "Turned: ON"
End If
End Sub


i want to toggle on and off
 
Last edited:

Crazywink

Hacker
Meme Tier VIP
Dank Tier Donator
Jul 18, 2012
626
4,613
17
C#:
If ((Keyboard.GetKeyStates(Key.NumPad1) > 0) And hotkey1 = True) Then
label1.Text = "Turned on"
I haven't tested it & I don't do anything in VB anymore, but this should work. :)

Complete vb.net memory class Source Code - Nether's VB Memory Class
 
Last edited by a moderator:

Heisa

Jr.Coder
Full Member
Nobleman
Jul 3, 2013
77
703
3
Easy

C++:
bool Aimbot = false;

if(GetAsyncKeyState(VK_TheKeyYouWant)) 
Aimbot = !Aimbot;
Simple toggle.
 

squeenie

Hacker
Meme Tier VIP
Dank Tier Donator
Mar 6, 2013
677
5,478
37
That's not VB.NET that's C++....
It's not very hard to change that into vb...

C++:
if  GetAsyncKeyState(Keys.NumPad1)
toggle = !toggle
Your hotkey turns the hack on if the button is pressed, but there is no code to turn it off.
 

ZxPwd

Newbie
Full Member
Jun 2, 2014
25
658
0
C#:
If ((Keyboard.GetKeyStates(Key.NumPad1) > 0) And hotkey1 = True) Then
label1.Text = "Turned on"
I haven't tested it & I don't do anything in VB anymore, but this should work. :)

Thanks for the reply I tried it and it didn't work. I managed to get this but I cant get the hack to turn off, I can only get it to turn on


C#:
    Private Sub hotkey_Tick(sender As Object, e As EventArgs) Handles hotkey.Tick
    
        Dim hotkey1 As Boolean

        If (GetAsyncKeyState(Keys.NumPad0) And 1) > 0 Then
            ''user pressed the key for 'toggle hack1' 

            hotkey1 = Not hotkey1 '' toggle the value

            If hotkey1 Then
                '' TODO: call Hack1Enable() here
                lblChange.Text = "Hack enabled"
            Else
                ''TODO: call Hack1Disable() here
                lblChange.Text = "Hack disabled"
            End If
        End If

    End Sub
 
Last edited:

Crazywink

Hacker
Meme Tier VIP
Dank Tier Donator
Jul 18, 2012
626
4,613
17
Yeah, squeenie's right, it's because you have hotkey1 in your timer tick, so every time it ticks it's recreating it and setting it to false.

Just place

C#:
Dim hotkey1 As Boolean
above the timer tick so it's global
 

ZxPwd

Newbie
Full Member
Jun 2, 2014
25
658
0
Yeah, squeenie's right, it's because you have hotkey1 in your timer tick, so every time it ticks it's recreating it and setting it to false.

Just place

C#:
Dim hotkey1 As Boolean
above the timer tick so it's global


Hey man thanks a lot you rock guys I REALLY appreciate the help 100% works THANKS! (GUIDEDHAKCING ROCKS!)

Final code:
C#:
    Dim hotkey1 As Boolean
    Private Sub hotkey_Tick(sender As Object, e As EventArgs) Handles hotkey.Tick
    
        If (GetAsyncKeyState(Keys.NumPad0) And 1) > 0 Then
            ''user pressed the key for 'toggle hack1' 

            hotkey1 = Not hotkey1 '' toggle the value

            If hotkey1 Then
                '' TODO: call Hack1Enable() here
                lblChange.Text = "Hack enabled"
            Else
                ''TODO: call Hack1Disable() here
                lblChange.Text = "Hack disabled"
            End If
        End If

    End Sub
____________________________________________________________________________
 
Last edited:
Status
Not open for further replies.
Attention! Before you post:

Read the How to Ask Questions Guide
99% of questions are answered in the Beginner's Guide, do it before asking a question.

No Hack Requests. Post in the correct section.  Search the forum first. Read the rules.

How to make a good post:

  • Fill out the form correctly
  • Tell us the game name & coding language
  • Post everything we need to know to help you
  • Ask specific questions, be descriptive
  • Post errors, line numbers & screenshots
  • Post code snippets using code tags
  • If it's a large project, zip it up and attach it

If you do not comply, your post may be deleted.  We want to help, please make a good post and we will do our best to help you.

Community Mods