[Dll] Flaming Hotkeys, Really simple to use

Discussion in 'Programming General' started by Flaming Idiots, Apr 7, 2008.

[Dll] Flaming Hotkeys, Really simple to use
  1. Unread #1 - Apr 7, 2008 at 9:21 AM
  2. Flaming Idiots
    Joined:
    Dec 22, 2005
    Posts:
    235
    Referrals:
    1
    Sythe Gold:
    0
    Two Factor Authentication User

    Flaming Idiots Active Member
    Visual Basic Programmers

    [Dll] Flaming Hotkeys, Really simple to use

    I really hate how Windows normally handles hotkeys, so I decided to make my own way for it.

    To use it add a reference to "Flaming Hotkeys.dll".
    Then you will need to create subs which do whatever you want the hotkeys to do, tag them with an attribute (Which you use to set the keys and name), and tell it to find the hotkeys.

    Here is an example:
    Code:
    Imports Flaming.Hotkeys
    
    Public Class MainWindow
    
        Private Sub MainWindow_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Hotkeys.FindHotkeys(Me)
        End Sub
    
        <HotKey("Help", ModKeys.None, Keys.F1)> _
        Public Sub Help()
            Static Count As Integer = 0
            Count += 1
            Me.Text = String.Format("F1 Pressed {0} Times", Count)
        End Sub
    
        <HotKey("Hide/Show", ModKeys.None, Keys.Escape)> _
        Public Sub HideShow()
            Me.Visible = Not Me.Visible
        End Sub
    
    End Class
    
    To Enabled/Disable a hotkey, you just need to do the following:
    Code:
    Hotkeys.Hotkeys("Help").Enabled = False
    You can also do more a more advanced way of making the hotkeys figure out if they are enabled like this:
    Code:
    Hotkeys.Hotkeys("Help").Enabled = BooleanExpression.Function(Function() Me.ContainsFocus)
    ' This will make the Help hotkey only work if it the form has focus.
    
    FInally, you must specify a Modifier key (Alt, Control, Shift) unless they key is an F key, Pause or Escape.
     

    Attached Files:

  3. Unread #2 - Apr 7, 2008 at 8:27 PM
  4. Elkins121
    Joined:
    Sep 18, 2007
    Posts:
    63
    Referrals:
    0
    Sythe Gold:
    0

    Elkins121 Member

    [Dll] Flaming Hotkeys, Really simple to use

    Thank you very much for this. I haven't actually looked at the script, or fooled around with the coding yet, but it seems very nice.

    I'm intermediate in VB programming, and this should add maneuverability and ease to my programs. Once again, thank you very much.
     
  5. Unread #3 - Apr 7, 2008 at 9:45 PM
  6. Nullware
    Joined:
    Jan 30, 2007
    Posts:
    1,761
    Referrals:
    4
    Sythe Gold:
    0

    Nullware Guru

    [Dll] Flaming Hotkeys, Really simple to use

    What method do you use in your DLL to implement hotkeys? Not GetAsyncKeyState on a timer I hope...
     
  7. Unread #4 - Apr 7, 2008 at 9:53 PM
  8. Flaming Idiots
    Joined:
    Dec 22, 2005
    Posts:
    235
    Referrals:
    1
    Sythe Gold:
    0
    Two Factor Authentication User

    Flaming Idiots Active Member
    Visual Basic Programmers

    [Dll] Flaming Hotkeys, Really simple to use

    I use a global keyboard hook, and if they keys are pressed and it's enabled, it blocks the input and invokes the method.
     
< Powerful C++ Virus | The next step! >

Users viewing this thread
1 guest


 
 
Adblock breaks this site