24

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)");
Rohit Gupta
  • 4,022
  • 20
  • 31
  • 41
ALI
  • 241
  • 1
  • 2
  • 3

5 Answers5

45

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)");
Tisho
  • 8,320
  • 6
  • 44
  • 52
Chola
  • 449
  • 4
  • 5
16

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

Valamas
  • 24,169
  • 25
  • 107
  • 177
TexWiller
  • 318
  • 2
  • 9
6

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.

Andrii Omelchenko
  • 13,183
  • 12
  • 43
  • 79
user392757
  • 61
  • 1
4

Did you try

SendKeys.SendWait("^{A}"); 
  • tried this and this doesn't work. Tried use alt key combos and they don't work for me either.... – ALI Aug 07 '10 at 16:36
2

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");