Detect Combine Keys Cntrl + Enter with RawInput / Hook Keyboard RRS feed

  • Question

  • Hi All,

    I am developing an MS Excel VSTO Add-in and I have to track Keyboard input, i.e Cntrl+Enter key or any other combination etc. Till now what I have found is that you can do it with by Keyboard Hook SetWindowsHookEx function and other one is Raw Input . There is a blog about it as well that describe the why we should use Raw Input. Considering all this I have couple of questions:

    1. Raw Input Vs. SetWindowsHookEx API

    2. Raw Input only detects keys one by one not Combination. How can I do that?


    Attiqe Ur Rehman

    Wednesday, February 5, 2014 7:12 AM


All replies

  • Hello Attiqe,

    Setting a hook is a widely spread technique for intercepting keyboard buttons. Please take a look at the Using shortcut keys to call a function in an Office Add-in article for more information and sample code.

    • Proposed as answer by Marvin_Guo Thursday, February 6, 2014 8:47 AM
    • Marked as answer by Marvin_Guo Wednesday, February 12, 2014 11:40 AM
    Wednesday, February 5, 2014 7:07 PM
  • Eugene,

    Thanks for your reply. I read another article : http://molecularmusings.wordpress.com/2011/09/05/properly-handling-keyboard-input/ it gives some serious concerns about hook.

    Why should I use Key Hooks and why not Raw Input?


    Attiqe Ur Rehman

    Wednesday, February 5, 2014 7:15 PM
  • Actually, I've never used the Raw Input technique. The keyboard hooks are widely spread between add-in developers. It is up to you which approach is to choose.
    Wednesday, February 5, 2014 7:51 PM