locked
What is the method instead of SetWindowsHookEx in Metro style app?

    Question

  • Hi all,

    In the desktop I can use SetWindowsHookEx API to get into callback procure, such as keyboardproc, shellproc etc. But I can't use this API in my Metro style app.

    Does anyone can give me a advice that how can I get the same result of SetWindowsHookEx in Metro style app.

    Thank you.

    Mike Wu

    Tuesday, January 17, 2012 10:33 AM

Answers

  • You can handle keyboard events (KeyUp, KeyDown) within your own app.

    You cannot hook or handle events in other applications. Metro style apps cannot interact with other applications (except via Contracts). It is not possible to write a hotkey utility as a Metro style app.

    --Rob

    • Marked as answer by Bob_Bao Tuesday, February 7, 2012 6:00 AM
    Wednesday, January 18, 2012 5:04 AM
    Owner

All replies

  • Hi Mike,

    There is nothing similar to SetWindowsHookEx. Metro style apps are isolated and cannot interact with other applications.

    If you are looking to hook events within your own app then you can add Xaml event handlers and get called.

    --Rob

    Tuesday, January 17, 2012 7:09 PM
    Owner
  • Hi Rob
      "hook events within your own app then you can add Xaml event handlers and get called" ->  could we hook keyboard event(which Event)?
     Did it mean Metro style application could not implement application such like hotkey utility which hook specific key?

    Thanks. 

    Wednesday, January 18, 2012 3:01 AM
  • You can handle keyboard events (KeyUp, KeyDown) within your own app.

    You cannot hook or handle events in other applications. Metro style apps cannot interact with other applications (except via Contracts). It is not possible to write a hotkey utility as a Metro style app.

    --Rob

    • Marked as answer by Bob_Bao Tuesday, February 7, 2012 6:00 AM
    Wednesday, January 18, 2012 5:04 AM
    Owner