- How to Copy Text From Windows Command Prompt
- 1. Using CMD Edit Options
- 2. Using Clip Command
- Copy text from open windows and dialog boxes with GetWindowText
- Copy text from open windows
- Windows copy text from any window
- Answered by:
- Question
- Answers
- iSumsoft
- Tell You More about IT World
- How to Copy and Paste in Command Prompt on Windows 7/10
- Part 1: How to copy and paste in Windows 7 Command Prompt
- Step 1: Enable QuickEdit mode in Command Prompt
- Step 2: How to copy and paste in Windows 7 Command Prompt
- Part 2: How to copy and paste in Command Prompt on Windows 10
- How to copy and paste text from any windows application (second clipboard)
How to Copy Text From Windows Command Prompt
Command prompt is the soul of Windows operating system. If you’re a programmer, you may know it very well that how much important it is. There are tons of commands which can do almost anything with your computer. Sometimes you may need to copy the text from cmd window but there is no direct option to do this as like we can do in case of copying text from other editors.
In other words, you can’t select, copy, cut and paste anything directly in command prompt. Then how to do it? Fortunately, Windows provide another methods which can troubleshoot this problem. In this short tutorial, I will guide you how to do that. There are two different methods you can try. Let’s start with first one.
1. Using CMD Edit Options
Command prompt provides manual edit options using which you can select, copy and paste any text easily. Normally, we right-click on text to perform these task but in case of command prompt, these features are hidden. So here I will tell you how to find and use them. Follow these step by step instructions.
- First of all, open cmd.exe from start menu.
- Now when you want to copy the text, right-click on program title.
- A hidden menu will open. Here click on «Edit» option and then click «Mark» button.
Finally open your favorite editor, say I choose Notepad and paste all text inside it.
In this way, you can copy any desired text from Windows command prompt shell. There are few more task which you can do. For example, you can paste any text inside cmd or you can search for any word etc., I think you don’t need any explanation for them. Try it yourself.
2. Using Clip Command
This method is quite different from first one. Here we will use clip command. Before moving further, let me tell you about clip. It simply redirects the output of command line tool to the Windows clipboard which can be later pasted in other programs also.
One more important thing is that, it copies single command output only. You can’t use it to copy complete text of cmd as like you can do in first method. The basic syntax of clip command is — «Your command here | CLIP»
For example, SET /? | CLIP
This will copy all output of «Set /?» code. Actually when you’ll add «/?» symbol after any command then it will display the help information. In the same way, above code will automatically copy all help information of set command. Few other examples are as follows —
- DIR | CLIP — Display a list of all files and sub-directories of a particular directory.
- HELP | CLIP — This will copy all cmd help information.
- TREE C:\ | CLIP — Display the graphical structure of your C drive folders.
- ECHO Hello | CLIP — This will simply copy «Hello» word.
After executing this clip command, go to your favorite editor, paste all text inside it and finally save it for future reference.
Additional Tip: There is another amazing use if clip command. You can also use it to copy text from any files. For example, if you’ve a txt file then clip command can copy all of its text. The basic syntax is —
Copy text from open windows and dialog boxes with GetWindowText
Many a time we need to copy error messages, error codes, or other text from images, dialog boxes, or open windows, which are otherwise “un-copy-able“. While one can always write down the text manually, this can be a pain if the text is too long.
If you are using Microsoft Office, you can use its in-built tool called Microsoft Office Document Imaging which will allow you to extract text from tiff and mdi files. We have also earlier seen freeware tools to copy text from images like OCR and Gttext.
Copy text from open windows
GetWindowText is a very small and portable program that allows you to read and copy the text in open windows.
If you have some open folder or a program window open and you need to copy the text in it you can do so easily using this tool. Simply click the left mouse-button on the GetWindowText icon on the left side and by holding down the left mouse button, the read can be started.
Then simply hold your mouse over the window from which the text should be read and copied. When you release the mouse button, the reading will be finished. The text will appear in the text-box which you can then copy.
This Windows freeware can be read almost all the texts from Edit, Static, Groupbox Controls, and so on. It also supports directory trees (SysTreeView32), combobox, and list views (SysListView32) to read the entire contents.
Get Window Text works on all Windows and supports x64 and x32 operating systems too.
Click here to download GetWindowText.
Take a look at Textify too.
Date: December 28, 2018 Tags: Explorer, Freeware
Windows copy text from any window
This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.
Answered by:
Question
I have a small COM application which is running in the background of my system. This application has to react when user selects a text and press a preconfigured global hot key. I am able to get a hook on the keyboard, but am not able to get the selected text from the window.
In simple words, how do i get the selected text from any window? I dont want to use the Clipboard functionality as I dont want to have the global hot key as CTRL-C.
I am working on C#, .Net Framework : 3.5. Any inputs of how to do this?
Answers
There are two steps to do this:
1. Get the focused control. We can get the current activated window via GetForegroundWindow API, then call GetWindowThreadProcessId API to get the thread id of the current window. If it is not the current thread, call AttachThreadInput API to attach the thread to the current thread. With all these jobs done, we can call GetFocus API to get the focused control handle.
2. Get the text of the focused control. We can call SendMessageW API to send a WM_GETTEXT message to do this.
You can get detail from the code below:
Let me know if this does not help.
Aland Li
Please mark the replies as answers if they help and unmark if they don’t. This can be beneficial to other community members reading the thread.
iSumsoft
Tell You More about IT World
- Blog>
- Windows 10>
- How to Copy and Paste in Command Prompt on Windows 7/10
How to Copy and Paste in Command Prompt on Windows 7/10
Usually, we enter commands manually in the Command Prompt on Windows 10/8/7. In fact, you can directly copy and paste text in Command Prompt if you want, which will save your time. Now, this post will show you how to copy and paste in Command Prompt on Windows 7/10.
Part 1: How to copy and paste in Windows 7 Command Prompt
By default, you cannot select or copy and paste text in the Command Prompt (or CMD) in Windows 7, before you enable its QuickEdit mode.
Step 1: Enable QuickEdit mode in Command Prompt
1) Open a Command Prompt (or CMD) window.
2) Right-click on the window’s title bar, and select Properties from the menu.
3) In the Properties dialog, select the Options tab, then check the QuickEdit Mode option under Edit Options, and click OK.
Step 2: How to copy and paste in Windows 7 Command Prompt
1) Select to highlight any text in the CMD window, using your left mouse button.
2) Press your right mouse button, or press the Enter key on your keyboard, or right click on the CMD window’s title bar and select Edit > Copy, so that the selected text can be copied.
3) Right-click in the command prompt window or right click on the window’s title bar and select Edit > Paste so that the selected text can be pasted onto your mouse cursor’s location in the CMD window. If you want to paste the selected text from the CMD window to another program or location, use Ctrl + V keyboard shortcuts.
4) Copy any text from another program or location, then right click in the Command Prompt window, or right click on the window’s title bar and select Edit > Paste, to paste the selected text onto the CMD window.
Part 2: How to copy and paste in Command Prompt on Windows 10
By default, you can freely select text or use Ctrl + C and Ctrl + V to copy and paste text in the Command Prompt (or CMD) of Windows 10. But if this feature is disabled by someone, you can enable it.
Step 1: Open a Command Prompt (or CMD) window.
Step 2: Right-click on the window’s title bar, and select Properties.
Step 3: In the Properties dialog, select the Options tab, uncheck Use legacy console (requires relaunch), keep the options under Edit Options and Text Selection checked, and then click OK.
Step 4: Close the current command prompt window, and relaunch the Command Prompt for the changes to take effect.
So, you can freely use the Ctrl + C and Ctrl + V to copy and paste text in a Command Prompt window, or between multiple CMD windows, or between a Command Prompt window and other programs.
How to copy and paste text from any windows application (second clipboard)
I have a windows desktop application in c# (WPF), which is basically an issue managing application for a call center. It manages (adds, edits, deletes. ) customer issues (records in database), where each issue has numerous fields (textboxes, textareas, checkboxes. ) While the issue is generated, a user often copies/pastes data from other resources to this and other applications (excel, notepad, browser. ), and has a windows clipboard full of valuable data.
The problem i don’t know how to solve is: A user selects a random text in any textfield (textbox for example) in this program, and copies the data. but this data can’t be copied to the clasic windows clipboard
because clipboard already has a valuable data, that can’t be lost. So i’d like to create a second clipboard which listens to all keyboard input. And whenever a certain combination of keys is pressed it reads the selected text (only text is needed), from any application (notepad, excel, my program. ). Similarly with another combination of keys it pastes that copied text to any application (notepad, excel. )
Windows already has that functionaliy with the shortcuts CTRL+C and CTRL+V, which work in any application that doesn’t override those shortcuts. I’d like to the same for my custom clipboard application/service, with different shortcuts. But i don’t know how to get and paste the data to any textfield in any windows application. In a nutshell, i’d need something like:
Basicaly i’d like to have two windows clipboards.
Any pointers would be great. Thank you.
found the solution for hooking up to the keys pressed here global keyboard hook Still looking for a way to «hook up» to active apps and selected text for copying and focused controls for pasting copied text.