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

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

    2. <tfoot id='tJfe0'></tfoot>
    3. 如何在 C# 中阻止键盘和鼠标输入?

      时间:2023-07-26

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

              • <small id='zfqXA'></small><noframes id='zfqXA'>

                本文介绍了如何在 C# 中阻止键盘和鼠标输入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在寻找一些可以阻止键盘和鼠标输入的代码(最好是 C#).

                I'm looking for some code (preferably C#) that will prevent keyboard and mouse input.

                推荐答案

                扩展 Josh 的(正确)答案.这是该方法的 PInvoke 签名.

                Expanding on Josh's (correct) answer. Here's the PInvoke signature for that method.

                public partial class NativeMethods {
                
                    /// Return Type: BOOL->int
                    ///fBlockIt: BOOL->int
                    [System.Runtime.InteropServices.DllImportAttribute("user32.dll", EntryPoint="BlockInput")]
                    [return: System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)]
                public static extern  bool BlockInput([System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)] bool fBlockIt) ;
                
                }
                
                public static void BlockInput(TimeSpan span) {
                  try { 
                    NativeMethods.BlockInput(true);
                    Thread.Sleep(span);
                  } finally {
                    NativeMethods.BlockInput(false);
                  }
                }
                

                编辑

                添加了一些代码来演示如何阻止间隔

                Added some code to demonstrate how to block for an interval

                这篇关于如何在 C# 中阻止键盘和鼠标输入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何在c#中获取组合键 下一篇:如何将密钥而不是字符发送到进程?

                相关文章

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

                    <small id='6iWCw'></small><noframes id='6iWCw'>

                      <bdo id='6iWCw'></bdo><ul id='6iWCw'></ul>