HOTKEYS ARGHHH

Posts 18 of 8 · Page 1 of 1
HOTKEYS ARGHHH
Can someone help me with hotkeys?
I can never get them to work.
I want to make a hotkey that i can use in-game!

Please someone help me..

Thanks
acid_buRn
They used to not work for me either, but then I now have 2 OS's on my PC, cause my first 1 got fked up by AleinWare, and now it works, I had
Windows XP Home,
Now I have Windows XP Professional

I will make a tutorial on it in a second
Needed:
- A Timer
- A Label (For testing if it works)

Code:

Put this under "Public Class *****"
Code:
Public Declare Function GetAsyncKeyState Lib "User32" (ByVal vKey As Long) As Integer
Then add this code to your timer:

Code:
Dim HotkeyTrue as Boolean
HotkeyTrue = GetAsyncKeyState(Keys.F12) 'F12 is the hotkey
If HotkeyTrue = true Then
Label1.Text = "True"
End if
Code:
Dim HotkeyFalse as Boolean
HotkeyFalse = GetAsyncKeyState(Keys.F11) 'F11 is the hotkey
If HotkeyFalse = True Then
Label1.Text = "False"
End if
Extra:
Enable the timer for the hotkeys.
Set the interval for the hotkeys to 15 millseconds (To prevent lag)



Code tested by me and it works.
Quote Originally Posted by Erinador View Post
Needed:
- A Timer
- A Label (For testing if it works)

Code:

Put this under "Public Class *****"
Code:
Public Declare Function GetAsyncKeyState Lib "User32" (ByVal vKey As Long) As Integer
Then add this code to your timer:

Code:
Dim HotkeyTrue as Boolean
HotkeyTrue = GetAsyncKeyState(Keys.F12) 'F12 is the hotkey
If HotkeyTrue = true Then
Label1.Text = "True"
End if
Code:
Dim HotkeyFalse as Boolean
HotkeyFalse = GetAsyncKeyState(Keys.F11) 'F11 is the hotkey
If HotkeyFalse = True Then
Label1.Text = "False"
End if
Extra:
Enable the timer for the hotkeys.
Set the interval for the hotkeys to 15 millseconds (To prevent lag)



Code tested by me and it works.
Thanks for that,
Bombsaway707 helped me out yesterday with a very simple code.

Thanks anyway
Why doesn't this work:

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 Hotkeyf12, hotkeyq As Boolean
        Dim counter As Integer
        Hotkeyf12 = GetAsyncKeyState(Keys.F12) 'F12 is the hotkey
        hotkeyq = GetAsyncKeyState(Keys.Q)
        If Hotkeyf12 = True Then
            counter = (counter + 1)
            Label1.Text = Str(counter)
        Else
            counter = counter
        End If
        If hotkeyq = True Then
            Close()
        End If

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim counter As Integer = 0
        Label1.Text = Str(counter)
        Timer1.Enabled = True
    End Sub
End Class
Quote Originally Posted by gwentravolta View Post
Why doesn't this work:

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 Hotkeyf12, hotkeyq As Boolean
        Dim counter As Integer
        Hotkeyf12 = GetAsyncKeyState(Keys.F12) 'F12 is the hotkey
        hotkeyq = GetAsyncKeyState(Keys.Q)
        If Hotkeyf12 = True Then
            counter = (counter + 1)
            Label1.Text = Str(counter)
        Else
            counter = counter
        End If
        If hotkeyq = True Then
            Close()
        End If

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim counter As Integer = 0
        Label1.Text = Str(counter)
        Timer1.Enabled = True
    End Sub
End Class
have you tried declaring outside?

usually i dont do declarations inside events/functions

well thats just me XD
Quote Originally Posted by deocute View Post
have you tried declaring outside?

usually i dont do declarations inside events/functions

well thats just me XD
well it was working for the "true" "false" stuff, so i thought it would still work. i normally declare outside too. i'm thinking maybe i'ts going too fast fo my computer? but then again, adding 1 shouldn't take up any memory at all that or somehow it's getting reset to 0 every time
Quote Originally Posted by gwentravolta View Post
well it was working for the "true" "false" stuff, so i thought it would still work. i normally declare outside too. i'm thinking maybe i'ts going too fast fo my computer? but then again, adding 1 shouldn't take up any memory at all that or somehow it's getting reset to 0 every time
coz every time the timer ticks it makes new variables, it declares every tick, thats why its resetting its values,

uhmm try it outside, the declaration part
Posts 18 of 8 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

Need help?