Results 1 to 21 of 21

Thread: Register Global HotKeys

Threaded View

  1. #3

    Thread Starter
    Hyperactive Member DavesChillaxin's Avatar
    Join Date
    Mar 2011
    Location
    WNY
    Posts
    451

    Re: Register Global HotKeys

    Yeah maramor that's not a problem, and sorry I never provided an example. Kind of put this up quick but here's what I got for you.

    First you're going to want to create an instance of the HotKeyRegistryClass class.


    vbnet Code:
    1. Dim HotKeyRegistry As New HotKeyRegistryClass()


    Second, begin to add items too this new instance of the class. In this case they are the HotKeys located in namespace Collections.Items.

    vbnet Code:
    1. ' this one will fire simply by pressing the 'A' key.
    2. Dim hk1 As new Collections.Items.HotKey(1,, Keys.A)
    3. ' this one will fire when you hit the 'A' key, plus Ctrl+Alt.
    4. Dim hk2 As new Collections.Items.HotKey(2, Windows.Keys.MOD_CTRL Or Windows.Keys.MOD_ALT, Keys.A)
    5.  
    6. HotKeyRegistry.RegisterGlobalHotKey(Form1.Handle, hk1)
    7. HotKeyRegistry.RegisterGlobalHotKey(Form1.Handle, hk2)


    Thats it!

    To unregister the hotkey's pass that same Form1.Handle and the hk you're going to unregister to the HotKeyRegistry.UnregisterGlobalHotKey method


    Make sure you place the last bit of code I provided in my original post in the forms code you plan on using to catch these key presses with.

    Hope this helps.. and I'm sure my name spaces didn't help at all. Enjoy!


    EDIT: Honestly having only worked in a professional setting for 2 months, have I noticed I would change sooo much with what I have here.. Perhaps I'll do an update in a few, haven't been doing much at home now that I code 5 days a week, 8 hours a day.
    Last edited by DavesChillaxin; Apr 18th, 2012 at 10:23 PM.
    Please rate if my post was helpful!
    Per favore e grazie!




    Code Bank:
    Advanced Algebra Class *Update | True Gradient Label Control *Dev | A Smarter TextBox *Update | Register Global HotKey *Update
    Media Library Beta *Dev | Mouse Tracker (Available in VB.net and C#.net) *New | On-Screen Numpad (VB.net) *New

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width