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

    Thumbs up 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
    Jorndel's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    Norway
    Posts
    8,676
    Reputation
    905
    Thanks
    19,113
    My Mood
    Angelic
    <DllImport("user32.dll", CharSet:=CharSet.Auto, ExactSpelling:=True)> _
    Public Shared Function GetKeyState(ByVal virtualKeyCode As Keys) As Boolean
    End Function
    Example:

    Timer1_Tick Event:

    If GetKeyState(Keys.F1) Then MessageBox.Show("Pressed Key: F1")


    Timer 1:
    Interval: 100 /Or what you like
    Enabled: True /To have it active

     
    Contributor 01.27.2012 - N/A
    Donator 07-17-2012 - Current
    Editor/Manager 12-16-12 - N/A
    Minion 01-10-2013 - 07.17.13
    Former Staff 09-20-2012 - 01-10-2013 / 07-17-2013 - Current
    Cocksucker 20-04-2013 - N/A

  3. #3
    Cryptonic's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    United Provinces of Canada
    Posts
    1,313
    Reputation
    44
    Thanks
    190
    My Mood
    Bored
    Quote Originally Posted by Jorndel View Post


    Example:

    Timer1_Tick Event:





    Timer 1:
    Interval: 100 /Or what you like
    Enabled: True /To have it active
    Isn't it better to declare a single hotkey as boolean or declare multiple hotkeys as a single boolean and use And in between, then say

    If ahotkey = true and bhotkey = True Then
    'something happens
    End If

    That's what I use.

  4. #4
    Jorndel's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    Norway
    Posts
    8,676
    Reputation
    905
    Thanks
    19,113
    My Mood
    Angelic
    Quote Originally Posted by PepsiXHacker View Post


    Isn't it better to declare a single hotkey as boolean or declare multiple hotkeys as a single boolean and use And in between, then say

    If ahotkey = true and bhotkey = True Then
    'something happens
    End If

    That's what I use.
    You do as you please OFC
    I just informed him about the function and gave an example on how to use it
    Last edited by Jorndel; 05-04-2013 at 09:27 AM.

     
    Contributor 01.27.2012 - N/A
    Donator 07-17-2012 - Current
    Editor/Manager 12-16-12 - N/A
    Minion 01-10-2013 - 07.17.13
    Former Staff 09-20-2012 - 01-10-2013 / 07-17-2013 - Current
    Cocksucker 20-04-2013 - N/A

  5. #5
    Cryptonic's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    United Provinces of Canada
    Posts
    1,313
    Reputation
    44
    Thanks
    190
    My Mood
    Bored
    Quote Originally Posted by Jorndel View Post


    You do as you please OFC
    I just informed him about the function and gave an example on how to use it
    Yeah, under textbox1.textchanged

  6. #6
    Jorndel's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    Norway
    Posts
    8,676
    Reputation
    905
    Thanks
    19,113
    My Mood
    Angelic
    Quote Originally Posted by PepsiXHacker View Post


    Yeah, under textbox1.textchanged


    I removed the part as I didn't think correctly
    -You can hook an keyboard input to the process but... This could be detected by most games

    You have the form1.keydown/pressed event

    But as it's to be hotkey(s). That won't work

     
    Contributor 01.27.2012 - N/A
    Donator 07-17-2012 - Current
    Editor/Manager 12-16-12 - N/A
    Minion 01-10-2013 - 07.17.13
    Former Staff 09-20-2012 - 01-10-2013 / 07-17-2013 - Current
    Cocksucker 20-04-2013 - N/A

  7. #7
    Cryptonic's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Location
    United Provinces of Canada
    Posts
    1,313
    Reputation
    44
    Thanks
    190
    My Mood
    Bored
    Quote Originally Posted by Jorndel View Post




    I removed the part as I didn't think correctly
    -You can hook an keyboard input to the process but... This could be detected by most games

    You have the form1.keydown/pressed event

    But as it's to be hotkey(s). That won't work
    Keydown is glitchy for me
    I got the keydown to work I guess, but when I try to use e.SuppressKeyPress = True it fails. Though, if you want to talk about it go to the thread I made, don't wanna hijack thread :P

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

    Jorndel (05-04-2013)

  9. #8
    Pingo's Avatar
    Join Date
    Apr 2010
    Gender
    male
    Posts
    687
    Reputation
    24
    Thanks
    865
    My Mood
    Blah
    What i sometimes do is make the key only tick once so it wont repeat untill you release and press again.

    On a timer with 50 or lower. Doesn't really matter if you have it lower since it only ticks once anyway.

    Code:
    If Keystate(Keys.F2) Then MsgBox("Only execute once")
    Code:
    #Region "Keys"
    
        Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Keys) As Short
    
        Dim hKeys As New Dictionary(Of Keys, Boolean)
    
        Public Function Keystate(ByVal key As Keys) As Boolean
            Dim St As Integer = GetKeyState(key)
            If Not hKeys.ContainsKey(key) Then hKeys.Add(key, False)
            If St = -127 OrElse St = -128 Then
                If Not hKeys(key) Then
                    hKeys(key) = True
                    Return True
                End If
            Else
                hKeys(key) = False
                Return False
            End If
            Return False
        End Function
    
    #End Region

  10. #9
    DawgiiStylz's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Location
    Dawg House
    Posts
    7,811
    Reputation
    219
    Thanks
    2,896
    My Mood
    Tired
    I rather use RegisterHotKey API
    RegisterHotKey function (Windows)

    Can also be used as a global hotkey. I really dislike using the GetasynKeyState API

  11. #10
    ySoNoob's Avatar
    Join Date
    Aug 2012
    Gender
    male
    Location
    United States
    Posts
    622
    Reputation
    31
    Thanks
    2,250
    My Mood
    Fine
    well thx I got it last night but then it stoped working!
    ill fix it soon! but thx for your help
    /Solved



Similar Threads

  1. Hotkeys on vb program
    By ySoNoob in forum Alliance of Valiant Arms (AVA) Help
    Replies: 7
    Last Post: 05-06-2013, 02:15 PM
  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