Results 1 to 8 of 8
  1. #1
    ySoNoob's Avatar
    Join Date
    Aug 2012
    Gender
    male
    Location
    United States
    Posts
    622
    Reputation
    31
    Thanks
    2,250
    My Mood
    Fine

    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??



  2. #2
    wGRWGHWGRERGrgergergrg's Avatar
    Join Date
    Jun 2012
    Gender
    female
    Posts
    495
    Reputation
    16
    Thanks
    1,363
    My Mood
    Tired
    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

  3. The Following User Says Thank You to wGRWGHWGRERGrgergergrg For This Useful Post:

    ySoNoob (05-05-2013)

  4. #3
    ccman32's Avatar
    Join Date
    Oct 2010
    Gender
    male
    Location
    Germany
    Posts
    1,306
    Reputation
    325
    Thanks
    22,221
    My Mood
    Devilish
    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.
    Last edited by ccman32; 05-04-2013 at 07:21 PM.

  5. The Following User Says Thank You to ccman32 For This Useful Post:

    ySoNoob (05-05-2013)

  6. #4
    ySoNoob's Avatar
    Join Date
    Aug 2012
    Gender
    male
    Location
    United States
    Posts
    622
    Reputation
    31
    Thanks
    2,250
    My Mood
    Fine
    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



  7. #5
    _Anonymous_'s Avatar
    Join Date
    Nov 2012
    Gender
    male
    Location
    (Not Applicable)
    Posts
    71
    Reputation
    10
    Thanks
    1,043
    My Mood
    Drunk
    @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
    Last edited by _Anonymous_; 05-05-2013 at 11:02 AM.

  8. The Following User Says Thank You to _Anonymous_ For This Useful Post:

    ySoNoob (05-05-2013)

  9. #6
    ySoNoob's Avatar
    Join Date
    Aug 2012
    Gender
    male
    Location
    United States
    Posts
    622
    Reputation
    31
    Thanks
    2,250
    My Mood
    Fine
    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...?



  10. #7
    wGRWGHWGRERGrgergergrg's Avatar
    Join Date
    Jun 2012
    Gender
    female
    Posts
    495
    Reputation
    16
    Thanks
    1,363
    My Mood
    Tired
    Timer i would say and the timerinterwall= macro speed

  11. #8
    ySoNoob's Avatar
    Join Date
    Aug 2012
    Gender
    male
    Location
    United States
    Posts
    622
    Reputation
    31
    Thanks
    2,250
    My Mood
    Fine
    /close
    /solved



  12. The Following User Says Thank You to ySoNoob For This Useful Post:

    GGabriel12 (05-08-2013)

Similar Threads

  1. [Solved] Hotkeys on VB Program
    By ySoNoob in forum Visual Basic Programming
    Replies: 9
    Last Post: 05-05-2013, 08:00 AM
  2. Replies: 12
    Last Post: 02-23-2011, 03:45 AM
  3. [Release] How To Add Hotkeys To Your Programs/Hacks
    By **HACKER** in forum CrossFire Tutorials
    Replies: 1
    Last Post: 01-06-2011, 02:43 PM
  4. [Help] How to close a program with a hotkey (VB6).
    By wr194t in forum Visual Basic Programming
    Replies: 7
    Last Post: 11-22-2007, 06:07 AM
  5. Hotkeys in C++
    By Dave84311 in forum C++/C Programming
    Replies: 7
    Last Post: 09-07-2007, 07:13 AM