Click here to Skip to main content
15,919,178 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to Select all a text in another program, by using "SendKeys".
I did it for a Notepad file:

C#
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?
Posted
Comments
Richard MacCutchan 31-May-15 4:22am    
That will only work if the other program responds to Ctrl+A by selecting all its text.

1 solution

It will depend on the "other program" and how it responds to keyboard input - there is no "system wide" Select All function, many programs don;t even have one - or need one - so you can;t just assume that you can do this.
Sending CTRL+A as you have done may work - or it may do nothing, or something totally different depending on who coded it.

There is no generic way to "Select All" in a windows application that is guaranteed to work for all applications.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900