• <legend id='PWuFH'><style id='PWuFH'><dir id='PWuFH'><q id='PWuFH'></q></dir></style></legend>

      1. <small id='PWuFH'></small><noframes id='PWuFH'>

        • <bdo id='PWuFH'></bdo><ul id='PWuFH'></ul>
        <tfoot id='PWuFH'></tfoot>

        <i id='PWuFH'><tr id='PWuFH'><dt id='PWuFH'><q id='PWuFH'><span id='PWuFH'><b id='PWuFH'><form id='PWuFH'><ins id='PWuFH'></ins><ul id='PWuFH'></ul><sub id='PWuFH'></sub></form><legend id='PWuFH'></legend><bdo id='PWuFH'><pre id='PWuFH'><center id='PWuFH'></center></pre></bdo></b><th id='PWuFH'></th></span></q></dt></tr></i><div id='PWuFH'><tfoot id='PWuFH'></tfoot><dl id='PWuFH'><fieldset id='PWuFH'></fieldset></dl></div>

        在 c# (wpf) 中捕获 windows 键

        时间:2023-07-26

        <small id='r0khu'></small><noframes id='r0khu'>

        <i id='r0khu'><tr id='r0khu'><dt id='r0khu'><q id='r0khu'><span id='r0khu'><b id='r0khu'><form id='r0khu'><ins id='r0khu'></ins><ul id='r0khu'></ul><sub id='r0khu'></sub></form><legend id='r0khu'></legend><bdo id='r0khu'><pre id='r0khu'><center id='r0khu'></center></pre></bdo></b><th id='r0khu'></th></span></q></dt></tr></i><div id='r0khu'><tfoot id='r0khu'></tfoot><dl id='r0khu'><fieldset id='r0khu'></fieldset></dl></div>
            • <bdo id='r0khu'></bdo><ul id='r0khu'></ul>

                <tfoot id='r0khu'></tfoot>
                  <tbody id='r0khu'></tbody>

                <legend id='r0khu'><style id='r0khu'><dir id='r0khu'><q id='r0khu'></q></dir></style></legend>

                  本文介绍了在 c# (wpf) 中捕获 windows 键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我编写了一个小程序,在按下任何按钮时在屏幕上显示声音和图像.当我的一个小孩爬到我的腿上并开始敲击琴键时,我总是启动它,当然,随机的.

                  除了 2 个键外,它工作正常,其中一个是 ON/OFF 开关,另一个是 Windows 键.(我相信CTRL-ESC等价物)我可以在按下它时拦截它,但只有在开始菜单显示之后.

                  我使用的事件是 UIElement.KeyDown,到目前为止我所能想到的是:(e 是 KeyEventArgs)

                   if (e.Key == Key.LWin) e.Handled = true;

                  但恐怕开始窗口已经显示出来了.

                  我已经有 1 个答案,但很想知道是否有任何 wpf 支持?

                  我怀疑可能无法对主开关进行编程?否则,也欢迎任何帮助..

                  解决方案

                  你需要一个 键盘挂钩.不幸的是,这必须通过 P/Invoke 来完成;托管代码无法做到这一点.

                  查看 Scott Hanselman 的 Baby Smash!.它托管在 http://www.codeplex.com/babysmashcode plex> Github 在 https://github.com/shanselman/babysmash

                  或者,查看 CodeProject 上的 ShapeShow,类似.p>

                  I have written a small program displaying sounds and images on the screen when pushing any button. I always start it when one of my little kids crawls onto my lap and start hitting the keys, of course, randomly.

                  It works fine except for 2 keys, one of them being the ON/OFF switch, the other being the Windows-key. (the CTRL-ESC equivalent I believe) I can intercept it as it is pressed, but only after the startmenu is showing.

                  The event I use is the UIElement.KeyDown and all I could came up with so far is : (the e being KeyEventArgs)

                              if (e.Key == Key.LWin) e.Handled = true;
                  

                  but than the start window is already showing I'm afraid.

                  I have already 1 answer but would very much like to know if there's any wpf-support?

                  I suspect programming the main on/off switch might not be possible? Otherwise, any help there would be welcome too..

                  解决方案

                  You'll need a keyboard hook. Unfortunately, this has to be done with P/Invoke; it can't be done with managed code.

                  Check out Baby Smash! by Scott Hanselman. It's hosted on code plex at http://www.codeplex.com/babysmash Github at https://github.com/shanselman/babysmash

                  Alternatively, check out ShapeShow on CodeProject, which is similar.

                  这篇关于在 c# (wpf) 中捕获 windows 键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:最小化应用程序时捕获媒体密钥 下一篇:如何在 C# 中使用 RegisterHotKey()?

                  相关文章

                  • <bdo id='RIEJY'></bdo><ul id='RIEJY'></ul>
                1. <legend id='RIEJY'><style id='RIEJY'><dir id='RIEJY'><q id='RIEJY'></q></dir></style></legend>

                      <tfoot id='RIEJY'></tfoot>

                      <small id='RIEJY'></small><noframes id='RIEJY'>

                    1. <i id='RIEJY'><tr id='RIEJY'><dt id='RIEJY'><q id='RIEJY'><span id='RIEJY'><b id='RIEJY'><form id='RIEJY'><ins id='RIEJY'></ins><ul id='RIEJY'></ul><sub id='RIEJY'></sub></form><legend id='RIEJY'></legend><bdo id='RIEJY'><pre id='RIEJY'><center id='RIEJY'></center></pre></bdo></b><th id='RIEJY'></th></span></q></dt></tr></i><div id='RIEJY'><tfoot id='RIEJY'></tfoot><dl id='RIEJY'><fieldset id='RIEJY'></fieldset></dl></div>