Global Key Hook

Discussion in 'Programmer's Corner' started by KCHARROIS, Jun 8, 2014.

  1. KCHARROIS

    Thread Starter Member

    Jun 29, 2012
    292
    1
    Hello,

    I'm currently trying to write a program using global key hook. So what I'm trying to write is an if statement saying if keys A and B are pressed then do... else do... How can I write this?
     
  2. sirch2

    Well-Known Member

    Jan 21, 2013
    1,008
    351
    Did you look at the code I linked to in the other thread you posted on this? I think it depends on what you are trying to hook. I can't remember the details since it is a long time since I wrote one but IIRC things like Shift and Ctrl come in as modifiers in the event args?

    I'm not sure that the keyboard would actually send A and B simultaneously, Shift+A would work. Even if the key board did send A and B you would probably have two handlers so you could set a flag in the A handler and check for the flag in the B handler, and vice-versa.
     
  3. KCHARROIS

    Thread Starter Member

    Jun 29, 2012
    292
    1
    Yes, I checked out the code. I just want to write an if statement if say ctrl + x is pressed do something. Right now I can only do it with one key pressed.
     
  4. sirch2

    Well-Known Member

    Jan 21, 2013
    1,008
    351
Loading...