SendKeys Ctrl-A 不起作用

发布于 2024-09-13 06:46:21 字数 572 浏览 0 评论 0原文

我正在尝试发送 CTRL A (在本例中选择全部到应用程序,但尝试可能不起作用)我已经尝试了很多组合但都无济于事,有什么想法吗?

        IntPtr appHandle = FindWindow(null, "Document1 - Microsoft Word");
        if (appHandle == IntPtr.Zero)
        {
            MessageBox.Show("Specified app is not running.");
            return;
        }

        SetForegroundWindow(appHandle);
        System.Threading.Thread.Sleep(500);

        //SendKeys.SendWait("111");
        SendKeys.SendWait("^A");
        //SendKeys.SendWait("^(A)"); //ctrl a
        //SendKeys.SendWait("(^A)");

I'm trying to send CTRL A (select all to an app in this case word but try as I might it doesn't work) I've tried quite a few combinations but all to no avail, any ideas?

        IntPtr appHandle = FindWindow(null, "Document1 - Microsoft Word");
        if (appHandle == IntPtr.Zero)
        {
            MessageBox.Show("Specified app is not running.");
            return;
        }

        SetForegroundWindow(appHandle);
        System.Threading.Thread.Sleep(500);

        //SendKeys.SendWait("111");
        SendKeys.SendWait("^A");
        //SendKeys.SendWait("^(A)"); //ctrl a
        //SendKeys.SendWait("(^A)");

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

_畞蕅 2024-09-20 06:46:21

要指定在按下其他几个键时应按住 SHIFTCTRLALT 的任意组合,请附上这些键的代码括号内。例如,要指定在按下 EC 时按住 SHIFT,请使用 +(EC)。要指定在按下 E 时按住 SHIFT,然后按下 C,而不按下 SHIFT,请使用 +欧共体

答案是:

SendKeys.Send("^(a)");

To specify that any combination of SHIFT, CTRL, and ALT should be held down while several other keys are pressed, enclose the code for those keys in parentheses. For example, to specify to hold down SHIFT while E and C are pressed, use +(EC). To specify to hold down SHIFT while E is pressed, followed by C without SHIFT, use +EC.

Answer is:

SendKeys.Send("^(a)");
放飞的风筝 2024-09-20 06:46:21

我遇到了同样的问题
我想要选择文本,输入文本控件

SendKeys.SendWait("^A") 不起作用,Sendkeys.SendWait "^A" 不起作用

Sendkeys.SendWait("^a") 工作正常

以获取更多信息:
http://www.autoitscript.com/autoit3/docs/functions/Send。 htm

hth

I got same problem
I want select text an input text control

SendKeys.SendWait("^A") doesn't works nor Sendkeys.SendWait "^A" doessn't works

Sendkeys.SendWait("^a") works ok

for more info:
http://www.autoitscript.com/autoit3/docs/functions/Send.htm

hth

腻橙味 2024-09-20 06:46:21

SendKeys 区分大小写。试试这个:

SendKeys.Send("^a"); 

我不确定,但它似乎

SendKeys.Send("^A"); 

意味着 Ctrl+Shift+A。至少在某些应用中确实是这样工作的。

SendKeys is case-sensitive. Try this:

SendKeys.Send("^a"); 

I'm not sure, but it seems like

SendKeys.Send("^A"); 

means Ctrl+Shift+A. At least it does work this way in some applications.

ι不睡觉的鱼゛ 2024-09-20 06:46:21

你尝试过吗

SendKeys.SendWait("^{A}"); 

Did you try

SendKeys.SendWait("^{A}"); 
趴在窗边数星星i 2024-09-20 06:46:21

经历过这个。

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

找到要输入文本的元素

     element.SetFocus();

     Thread.Sleep(2000);

     SendKeys.SendWait("^{HOME}");  // Move to start of control

     SendKeys.SendWait("^+{END}"); // Select everything

     SendKeys.SendWait("{DEL}"); 

     SendKeys.SendWait("Value"); 

been through this.

The only working solution:

Find your element where you want to enter text

     element.SetFocus();

     Thread.Sleep(2000);

     SendKeys.SendWait("^{HOME}");  // Move to start of control

     SendKeys.SendWait("^+{END}"); // Select everything

     SendKeys.SendWait("{DEL}"); 

     SendKeys.SendWait("Value"); 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文