Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Okay, it is possible, and could indeed be useful if your application is deployed in an environment where a camera is not available to the user.</p> <p>First of all, I used the RegisterHotKey and UnregisterHotKey API calls, documented here <a href="http://pinvoke.net/default.aspx/user32.RegisterHotKey" rel="nofollow">http://pinvoke.net/default.aspx/user32.RegisterHotKey</a> as described in this rather old article here <a href="http://msdn.microsoft.com/en-us/magazine/cc163713.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/magazine/cc163713.aspx</a>.</p> <p>I registered the <code>IDHOT_SNAPDESKTOP</code> hotkey in the <code>Window_Load</code> event and unregistered it in the <code>Window_Closed</code>. Trying to do this in the constructor gave me problems getting a consistent handle with the <code>WindowInteropHelper(this)</code> method.</p> <p>If you'd like to do more than just ignore the keys you can set up a windows message handler, making a kind of WndProc using,</p> <pre><code>HwndSource source = HwndSource.FromHwnd(&lt;handle&gt;); source.AddHook(&lt;WndProc&gt;); </code></pre> <p>making the handle as described above, and the WndProc implementation yourself.</p> <p>As yet, I don't know how to "not" handle the hot key and get windows to perform its normal behaviour except, of course, by unregistering the hotkeys.</p> <p>Its not very elegant or "WPF" but it worked for me.</p> <hr> <p><strong>As @ghord comments</strong></p> <p>The use of <a href="http://msdn.microsoft.com/en-us/library/system.windows.interop.windowinterophelper.ensurehandle.aspx" rel="nofollow"><code>EnsureHandle()</code></a> looks useful for getting a handler in the constructor.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload