- Clipboard Operations
- Cut and Copy Operations
- Paste Operations
- Clipboard Ownership
- Delayed Rendering
- Memory and the Clipboard
- Copy text from a Windows CMD window to clipboard
- 8 Answers 8
- www.makeuseof.com
- Follow MUO
- How to Manage Your Windows Clipboard Like a Pro
- What Is the Clipboard?
- How to Save and View Clipboard History
- How to Clear Clipboard History
- Other Methods
- Use a Windows XP Trick to See Your Clipboard
- Wiping Your Clipboard
- 1. Create a Dedicated Shortcut
- 2. Use a Registry Hack
- Third-Pary Clipboard Managers
- 1. Comfort Clipboard
- 2. ClipboardFusion
- Pro Tip: Use Notepad to Remove Formatting
- Subscribe To Our Newsletter
- One More Step…!
Clipboard Operations
A window should use the clipboard when cutting, copying, or pasting data. A window places data on the clipboard for cut and copy operations and retrieves data from the clipboard for paste operations. The following sections describe these operations and related issues.
To place data on or retrieve data from the clipboard, a window must first open the clipboard by using the OpenClipboard function. Only one window can have the clipboard open at a time. To find out which window has the clipboard open, call the GetOpenClipboardWindow function. When it has finished, the window must close the clipboard by calling the CloseClipboard function.
The following topics are discussed in this section.
Cut and Copy Operations
To place information on the clipboard, a window first clears any previous clipboard content by using the EmptyClipboard function. This function sends the WM_DESTROYCLIPBOARD message to the previous clipboard owner, frees resources associated with data on the clipboard, and assigns clipboard ownership to the window that has the clipboard open. To find out which window owns the clipboard, call the GetClipboardOwner function.
After emptying the clipboard, the window places data on the clipboard in as many clipboard formats as possible, ordered from the most descriptive clipboard format to the least descriptive. For each format, the window calls the SetClipboardData function, specifying the format identifier and a global memory handle. The memory handle can be NULL, indicating that the window renders the data on request. For more information, see Delayed Rendering.
Paste Operations
To retrieve paste information from the clipboard, a window first determines the clipboard format to retrieve. Typically, a window enumerates the available clipboard formats by using the EnumClipboardFormats function and uses the first format it recognizes. This method selects the best available format according to the priority set when the data was placed on the clipboard.
Alternatively, a window can use the GetPriorityClipboardFormat function. This function identifies the best available clipboard format according to a specified priority. A window that recognizes only one clipboard format can simply determine whether that format is available by using the IsClipboardFormatAvailable function.
After determining the clipboard format to use, a window calls the GetClipboardData function. This function returns the handle to a global memory object containing data in the specified format. A window can briefly lock the memory object in order to examine or copy the data. However, a window should not free the object or leave it locked for a long period of time.
Clipboard Ownership
The clipboard owner is the window associated with the information on the clipboard. A window becomes the clipboard owner when it places data on the clipboard, specifically, when it calls the EmptyClipboard function. The window remains the clipboard owner until it is closed or another window empties the clipboard.
When the clipboard is emptied, the clipboard owner receives a WM_DESTROYCLIPBOARD message. Following are some reasons why a window might process this message:
- The window delayed rendering of one or more clipboard formats. In response to the WM_DESTROYCLIPBOARD message, the window might free resources it had allocated in order to render data on request. For more information about the rendering of data, see Delayed Rendering.
- The window placed data on the clipboard in a private clipboard format. The data for private clipboard formats is not freed by the system when the clipboard is emptied. Therefore, the clipboard owner should free the data upon receiving the WM_DESTROYCLIPBOARD message. For more information about private clipboard formats, see Clipboard Formats.
- The window placed data on the clipboard using the CF_OWNERDISPLAY clipboard format. In response to the WM_DESTROYCLIPBOARD message, the window might free resources it had used to display information in the clipboard viewer window. For more information about this alternative format, see Owner Display Format.
Delayed Rendering
When placing a clipboard format on the clipboard, a window can delay rendering the data in that format until the data is needed. To do so, an application can specify NULL for the hData parameter of the SetClipboardData function. This is useful if the application supports several clipboard formats, some or all of which are time-consuming to render. By passing a NULL handle, a window renders complex clipboard formats only when and if they are needed.
If a window delays rendering a clipboard format, it must be prepared to render the format upon request for as long as it is the clipboard owner. The system sends the clipboard owner a WM_RENDERFORMAT message when a request is received for a specific format that has not been rendered. Upon receiving this message, the window should call the SetClipboardData function to place a global memory handle on the clipboard in the requested format.
An application must not open the clipboard before calling SetClipboardData in response to the WM_RENDERFORMAT message. Opening the clipboard is not necessary, and any attempt to do so will fail because the clipboard is currently being held open by the application that requested the format to be rendered.
If the clipboard owner is about to be destroyed and has delayed rendering some or all clipboard formats, it receives the WM_RENDERALLFORMATS message. Upon receiving this message, the window should open the clipboard, check that it is still the clipboard owner with the the GetClipboardOwner function, and then place valid memory handles on the clipboard for all clipboard formats that it provides. This ensures that these formats remain available after the clipboard owner is destroyed.
Unlike with WM_RENDERFORMAT, an application responding to WM_RENDERALLFORMATS should open the clipboard before calling SetClipboardData to place any global memory handles on the clipboard.
Any clipboard formats that are not rendered in response to the WM_RENDERALLFORMATS message cease to be available to other applications and are no longer enumerated by the clipboard functions.
Memory and the Clipboard
A memory object that is to be placed on the clipboard should be allocated by using the GlobalAlloc function with the GMEM_MOVEABLE flag.
After a memory object is placed on the clipboard, ownership of that memory handle is transferred to the system. When the clipboard is emptied and the memory object has one of the following clipboard formats, the system frees the memory object by calling the specified function:
Copy text from a Windows CMD window to clipboard
Does anyone know if it’s possible to copy text from a Windows’ command prompt or console window like the output of a command, console application or batch file?
8 Answers 8
- Right click > Mark
- Select the text you want to copy by holding left mouse button and selecting text OR by navigating to the beginning of the text you want to copy with the arrow keys, pressing Shift, and moving (with the arrow keys) to the end of the text.
- right click on the title bar, go into «Edit», and hit Copy.
Now you can paste in Notepad or in Command Prompt again by right-clicking on the title bar, going into «Edit», and hitting «Paste.»
Another option, if you know ahead of time that you want the results of a command to be placed on the clipboard, is to pipe your output to the CLIP utility.
Here are a two simple examples
Open a command window, then right click on the title bar and left click on Properties at bottom of context menu. On the Options tab add a check-mark at QuickEdit Mode. Click OK and in the next dialog select the second radio button so that every command window that you will open in future has got this option enabled. Close the dialog with OK.
Now you can select text using left click on your mouse. To copy the text to the clipboard, just press the Enter key.
Follow these steps:
- Move pointer with pointing device (mouse, touchpad, pointing stick, . ) over the window, press right button to open the context menu and left click on first context menu option Mark.
- After that action select the text with holding left button (rectangular selection).
- After selecting hit key Enter or Return to copy selected text to clipboard.
- Paste copied text anywhere with Ctrl+V .
www.makeuseof.com
Follow MUO
How to Manage Your Windows Clipboard Like a Pro
Better known as Copy & Paste, a tool for students to lift passages from Wikipedia, the Clipboard can save you loads of typing time. We’ll show you how to use it like a pro.
The Windows Clipboard can be your invaluable ally, saving you loads of typing time and enabling you to move content between documents with ease.
Today, we will be looking at ways to manage your clipboard, as well as provide some information on what it is and what you can do with it.
What Is the Clipboard?
The clipboard is a function that enables you to copy unlimited amounts of information and/or images; although it will probably slow your system down if you attempt to copy and paste hundreds of pages. It isn’t something unique to Windows. Other operating systems have a clipboard as well, albeit with different key combinations.
On Windows, you can copy something by highlighting the desired text, then activating the clipboard with the keyboard function CTRL + C. To paste the copied content, press CTRL + V.
The Clipboard does have its limitations though. Without some tweaks in the Settings menu, it can only save one thing at a time. Therefore, when you copy something, the clipboard automatically wipes the previous entry. The clipboard is also wiped when the computer is switched off or restarted.
How to Save and View Clipboard History
In mid-2018, Microsoft finally rolled out an all-new Windows clipboard. It lets you turn on clipboard history on a per device basis, or even sync your clipboard history between all the Windows devices connected to your Microsoft account.
To turn on the new features, head to Settings > System > Clipboard. Flick the toggles under Clipboard history and Sync across devices to suit your preferences.
Once enabled, you can press Win + V at any time to see your clipboard history—images and text are supported. If you leave both settings disabled, the native Windows clipboard will continue to work in the same way as it did pre-2018.
How to Clear Clipboard History
Assuming you’ve enabled Windows’ new clipboard features, you can clear items on an individual basis by pressing Win + V, clicking the three dots next to the entry you want to remove, and choosing Delete.
If you want to remove your entire clipboard history, open the Settings app and go to System > Clipboard > Clear Clipboard data > Clear.
Other Methods
Let’s assume you don’t want to turn on the new features. Perhaps, for privacy reasons, you’d rather not keep a complete record of everything you’ve copied. Can you still see what’s currently copied to the clipboard? And how can you wipe that item to make your clipboard blank?
Use a Windows XP Trick to See Your Clipboard
In Windows XP and Windows Vista, entering the command clipbrd.exe in the Run dialog would bring up the clipboard and its contents. Microsoft retired the feature in Windows 7.
However, if you can get access to either XP or Vista, the clipbrd.exe method still works; just move the EXE file over to Windows 1o. It’s easy to do. On either XP or Vista, go to the %windir%\system32 folder, highlight the EXE file, press CTRL + C, and move it to the same path in your Windows 10 installation.
If you don’t have a copy of XP or Vista, you can download the file directly from The Windows Club (WARNING: download will start automatically).
If the downloaded file doesn’t work, try running it in Windows XP Service Pack 2 compatibility mode. To make the change, right-click on the EXE file, go to Properties > Compatibility, mark the checkbox next to Run this program in compatibility mode for, and make the selection.
Wiping Your Clipboard
To quickly wipe your clipboard from prying eyes, there are three quick fixes you can use.
- Shutting down or restarting the system.
- Highlight some plain text and press CTRL+C to wipe anything you copied previously.
- Press the Print Screen key whilst looking at a blank document or similar.
There are also a couple of more advanced tricks you can try.
1. Create a Dedicated Shortcut
First, you could create a shortcut on the desktop which, when clicked, will wipe your clipboard.
Follow these steps to get a dedicated shortcut set up:
- Right-click on the desktop and choose New >Shortcut.
- In the shortcut box, type cmd /c «echo off | clip
- Click Next and give it a name, such as «Clear Clipboard».
- Click Finish.
If you right-click on the new shortcut and choose Properties, you can also give the shortcut a logo and a keyboard shortcut. However, it’s not necessary for the shortcut to work.
2. Use a Registry Hack
The second option involves editing the Windows registry. Remember, changing the wrong values in the registry can brick your system. It is advisable to make a backup of your registry settings before proceeding.
If you’re feeling confident, you can add an option to the right-click context menu on the desktop to clear the clipboard. Use the steps below to see how it’s done:
- Press Win + R to open the Run tool.
- Type regedit and press Enter.
- Navigate to HKEY_CLASSES_ROOT\Directory\Background\.
- In the left-hand pane, right-click on Shell and select New >Key.
- Give the new menu item a name, such as Clear Clipboard.
- Right-click on the new Clear Clipboard item, go to New >Key, and name it Command.
- In the right-hand panel, double-click on Default and choose Modify.
- In the Value Data box type cmd.exe /c echo off | clip.
- Click OK.
- Press F5 to refresh the registry and shut it down.
You will now see the Clear Clipboard entry in the desktop context menu. Again, you may have to restart the system to get it to work for the first time.
Third-Pary Clipboard Managers
Even with its new features, the native Windows clipboard is still somewhat basic. If you need a more powerful clipboard, you can turn to a third-party solution.
Here are two of our favorite alternative clipboard managers.
1. Comfort Clipboard
Comfort Clipboard is a paid app; a lifetime license is $20. It introduces many features you won’t find in the Windows app, including app icons for easy identification, editing, colored tags, hotkeys, and more.
2. ClipboardFusion
ClipboardFusion has a free and pro ($15) version. It supports macros, triggers, hotkeys, cloud sync, and even 256-bit clipboard encryption. All the features are available to some degree in the free version.
Pro Tip: Use Notepad to Remove Formatting
How many times have you copied something, then had to spend a few minutes fiddling because all the formatting was carried over, too?
If you paste text into Notepad before moving it to its final destination, Notepad will remove the rich formatting such as bold, italics, underlining, tables, font colors, embedded objects, and more.
If you’d like to learn more about clipboards on other devices, check our articles on the best iPhone clipboard managers and the best Chromebook clipboard managers.
Is your Windows desktop a little messy? Here are free desktop management apps that can help you organize your virtual clutter.
Dan joined MakeUseOf in 2014 and has been Partnerships Director since July 2020. Reach out to him for inquires about sponsored content, affiliate agreements, promotions, and any other forms of partnership. You can also find him roaming the show floor at CES in Las Vegas every year, say hi if you’re going. Prior to his writing career, he was a Financial Consultant.
Subscribe To Our Newsletter
Join our newsletter for tech tips, reviews, free ebooks, and exclusive deals!
One More Step…!
Please confirm your email address in the email we just sent you.