Search code examples
c#sendkeys

how to select all in another program?


I want to Select all a text in another program, by using " SendKeys". I did it for a Notepad file:

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

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

        SendKeys.SendWait("^a");

but in the program that I want to select all its text, ctrl+a is considered for other command.

What should I do?


Solution

  • To select all you should use Ctrl+A get handle of the application and send Ctrl+A

    SendKeyDown(KeyCode.CONTROL);
    SendKeyPress(KeyCode.KEY_A);