HotKeys

Discussion in 'Programming General' started by slashshot007, Nov 10, 2008.

HotKeys
  1. Unread #1 - Nov 10, 2008 at 5:33 PM
  2. slashshot007
    Joined:
    May 6, 2006
    Posts:
    164
    Referrals:
    0
    Sythe Gold:
    0

    slashshot007 Active Member

    HotKeys

    I was wondering if anyone could help me out for figuring out how to do hotkeys in C#.
    I could use getasynckeystate, but that wastes alot of cpu usage.

    I know its possible through registerhotkey, and unregisterhotkey. But i'm not quite sure how, if someone could explain to me.

    I really hate the win32 dll imports as well, so if anyone has another way without doing that, it would be SO appreciated
    but anyway will do.
     
  3. Unread #2 - Nov 11, 2008 at 2:14 AM
  4. Swan
    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner

    Swan When They Cry...
    Retired Global Moderator

    HotKeys

    I love library imports sometimes, gives you access to the system like you would have in C++. However, I must agree, they can be a bit confusing sometimes and often I prefer to use classes provided by .Net. However, C#'s API doesn't provide a way to register hotkeys (that I know of) without library imports.

    Here is a nice RegisterHotKey tutorial I found on Google:
    http://20.targetprocess.com/2006/10/hotkeys-binding-in-c-windows.html

    Or, if you find that difficult to understand, perhaps this:
    http://www.codeproject.com/KB/miscctrl/ashsimplehotkeys.aspx

    Have fun ;)
     
  5. Unread #3 - Nov 11, 2008 at 5:36 PM
  6. slashshot007
    Joined:
    May 6, 2006
    Posts:
    164
    Referrals:
    0
    Sythe Gold:
    0

    slashshot007 Active Member

    HotKeys

    swan, i have done all that before of the easier tutorial before, but i never quite understood any of what this meant:
    Code:
    protected override void WndProc(ref Message m)
    {
       if (m.Msg == 0x0312)
          this.Activate();
       base.WndProc(ref m);
    }
    what is 0x0312 ?

    edit:i looked at the first link, and that class contains all i need, i will test it out next chance i get. If it works, thanks in advance.
     
  7. Unread #4 - Nov 20, 2008 at 8:35 PM
  8. slashshot007
    Joined:
    May 6, 2006
    Posts:
    164
    Referrals:
    0
    Sythe Gold:
    0

    slashshot007 Active Member

    HotKeys

    swan, i was looking at the code i posted above, and i realized, there is only one message that all of the hotkeys would send off, and that would be 0X0312.

    which would mean that although i could register multiple hotkeys, it would always come down to being 0X0312, which would only activate one handler.

    I'll keep trying stuff out, but your help would be nice.
     
  9. Unread #5 - Nov 21, 2008 at 1:46 AM
  10. Swan
    Joined:
    Jan 23, 2007
    Posts:
    4,957
    Referrals:
    0
    Sythe Gold:
    0
    Sythe's 10th Anniversary Member of the Month Winner

    Swan When They Cry...
    Retired Global Moderator

    HotKeys

    0x0312 is a hexadecimal number - if you can find out what it means (I haven't a clue) that would be a good start. Hint: Hex numbers are prefixed with 0x.

    With this article: http://www.codeproject.com/KB/miscctrl/ashsimplehotkeys.aspx

    You will want to be examining point #3. I've just gotten home from school and I'm fairly weary, so I can't think at the moment but I'll have a look later if I have time.
     
< RuneScape not loading in .NET IDE? | We should have a subforum in java.... >

Users viewing this thread
1 guest


 
 
Adblock breaks this site