Hotkeys on vb program

Posts 1–8 of 8 · Page 1 of 1
Hotkeys on vb program
Hiya I have tried many things to setup hotkeys on my VB programs and I really need to know how to get it to work!
1 time I got it but only 1 worked!
and 1 time I saw it didn't work if u had a theme and use theme button!
Any help??
Quote Originally Posted by ySoNoob View Post
Hiya I have tried many things to setup hotkeys on my VB programs and I really need to know how to get it to work!
1 time I got it but only 1 worked!
and 1 time I saw it didn't work if u had a theme and use theme button!
Any help??


i use this way

Code:
<System.Runtime.InteropServices.DllImport("user32.dll")> _
    Private Shared Function GetAsyncKeyState(ByVal vkey As System.Windows.Forms.Keys) As Short

    End Function
now u can use hotkeys and here an example for a hotkey

Code:
Dim *name of ur hotkey* As Boolean = GetAsyncKeyState(Keys.F4)
u have to put into a timer with fast interwall
I have no idea why im even helping people here but just do this:
Code:
Private Declare Function GetKeyPress Lib "user32" Alias "GetAsyncKeyState" (ByVal key As Integer) As Integer
For example if you want to close the program with the Escape key (a perfect timer interval would be around 15-25):
Code:
 Private Sub ShutdownTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShutdownTimer.Tick

    If GetKeyPress(Keys.Escape) Then
            Me.Close()
    End If

 End Sub
Uncomplicated, no need of declaring new booleans and easy to use at all. The only problem i ever got with this was when it is part of a disabled timer. For example the timer is not ticking, you press the escape button and nothing happens of course. But right when you start the timer now it will close since for a split second the program thinks that the key is still pressed and runs the Me.Close part.
Quote Originally Posted by ccman32 View Post
I have no idea why im even helping people here but just do this:
Code:
Private Declare Function GetKeyPress Lib "user32" Alias "GetAsyncKeyState" (ByVal key As Integer) As Integer
For example if you want to close the program with the Escape key (a perfect timer interval would be around 15-25):
Code:
 Private Sub ShutdownTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ShutdownTimer.Tick

    If GetKeyPress(Keys.Escape) Then
            Me.Close()
    End If

 End Sub
Uncomplicated, no need of declaring new booleans and easy to use at all. The only problem i ever got with this was when it is part of a disabled timer. For example the timer is not ticking, you press the escape button and nothing happens of course. But right when you start the timer now it will close since for a split second the program thinks that the key is still pressed and runs the Me.Close part.
hey man thx for the help but r u gonna make anything else or contribute to the AVA hacks section??
if not tlk add me on Skype will talk...all I need is a macro for this game and im good! but I never used autoit before! xD
@ySoNoob for the macro

Code:
If GetAsyncKeyState(vbKeyLButton) then
             mouse_event MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0, 0
                      sleep & text1.text  'for ms settings
                           mouse_event MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0
                                       end if
if you think it's leech so be it
Quote Originally Posted by _Anonymous_ View Post
@ySoNoob for the macro

Code:
If GetAsyncKeyState(vbKeyLButton) then
             mouse_event MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0, 0
                      sleep & text1.text  'for ms settings
                           mouse_event MOUSEEVENTF_MIDDLEUP, 0, 0, 0, 0
                                       end if
if you think it's leech so be it

and what to do with this?? put it in a button?? or timer...?
/close
/solved
Posts 1–8 of 8 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?