【问题标题】:send ctr+A (select all) with SendKeys.Send()使用 SendKeys.Send() 发送 ctr+A(全选)
【发布时间】:2021-08-09 00:55:08
【问题描述】:

您好
我想将 CTR + A 发送到其他应用程序以选择文本框中的所有文本,但我不知道如何同时发送 2 个键
我拆分所有键并一一发送
对于我使用此代码的发送密钥:

System.Windows.Forms.SendKeys.Send(keys);

现在我如何同时发送 2 个键
或者我如何将 ctr + A 发送到其他应用程序以全选,我可以从 SendKeys 使用或有任何其他选项同时发送 ctr + A 或任何其他选项从另一个应用程序中选择所有文本?


谢谢。
亲切的问候,
山姆

【问题讨论】:

  • SendKeys 已经支持,请务必阅读 MSDN 文章。发送 Ctrl+A 只需要发送“^A”。 ^ 表示 Ctrl。

标签: c# .net sendkeys selectall


【解决方案1】:

感谢汉斯·帕桑特

回答: SendKeys 已经支持该功能,请务必阅读 MSDN 文章。发送 Ctrl+A 只需要发送“^A”。 ^ 表示 Ctrl。

【讨论】:

    【解决方案2】:

    经历过。

    唯一可行的解​​决方案:

    找到要输入文本的元素

     element.SetFocus();
    
     Thread.Sleep(2000);
    
     SendKeys.SendWait("^{HOME}");  // Move to start of control
    
     SendKeys.SendWait("^+{END}"); // Select everything
    
     SendKeys.SendWait("{DEL}"); 
    
     SendKeys.SendWait("Value");
    

    【讨论】:

      【解决方案3】:

      NumericUpDown 控件的 Enter 事件中:

      private void highlightNud_Event(object sender, EventArgs e)
      {
          SendKeys.Send("^A");
      }
      

      这为我工作了很多很多年(flawlessley)。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-12-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-12-04
        • 1970-01-01
        相关资源
        最近更新 更多