Access clipboard in windows

How to use the new clipboard on Windows 10 October 2018 Update

On Windows 10, you’ve been able to copy and paste text and images for a long time, but it’s been an experience somewhat limited that only supported copying one piece of content at a time and no interface to view the things you copied.

To overcome these limitations and to make the experience more useful, starting with the October 2018 Update, Windows 10 introduces a new clipboard that tracks the text and images (up to 4MB) that you copy. Also, you can finally view and paste content from the clipboard history, and even pin items that you copy and paste more frequently.

In addition, leveraging the same cloud technology use to sync your Timeline content, your clipboard history can now roam and be accessible across all your devices.

In this Windows 10 guide, we’ll walk you through the steps to set up and use the new cloud-powered clipboard experience included with the October 2018 Update.

How to enable clipboard on Windows 10

On Windows 10 version 1809, you can enable the new clipboard experience using the Settings app and the new keyboard shortcut.

Enabling clipboard using Settings

To enable clipboard in the Settings app, use these steps:

  1. Open Settings.
  2. Click on System.
  3. Click on Clipboard.

Turn on the Clipboard history toggle switch.

Enabling clipboard using a shortcut

Alternatively, to enable clipboard using a keyboard shortcut, use these steps:

    Use the Windows key + V keyboard shortcut.

Click the Turn on button.

After completing the steps, you can start using the clipboard experience and manage many other settings.

Disabling clipboard on Windows 10

The clipboard history device using the sis disabled by default, but you can check or disable it if the feature is turned on using these steps:

  1. Open Settings.
  2. Click on System.
  3. Click on Clipboard.

Turn off the Clipboard history toggle switch.

Once you’ve completed the steps, the new clipboard experience will no longer be available without affecting the old clipboard functionality.

How to sync clipboard history on Windows 10

Perhaps one of the most interesting features about the new clipboard is the ability to paste text and images on your other devices. However, for privacy reasons, it’s a feature that you must enable and configure manually using these steps:

  1. Open Settings.
  2. Click on System.
  3. Click on Clipboard.

Under «Sync across devices,» turn on the toggle switch.

Select the automatic syncing option you want to use:

  • Automatically sync text that I copy: Your clipboard history will sync to the cloud and across your devices.
  • Never automatically sync text that I copy: You must manually open the clipboard history and select the content you want to make available across devices.

After completing the steps, your content history will sync to the cloud and across devices using the settings you specified.

How to clear clipboard history on Windows 10

If you want to delete your clipboard history because you no longer want to use experience or something isn’t working correctly, and you want to reset the history to see if that fixes the problem, use these steps:

  1. Open Settings.
  2. Click on System.
  3. Click on Clipboard.

Under «Clear clipboard data,» click the Clear button.

Once you’ve completed the steps, your clipboard content will be deleted from your device and Microsoft account, but pinned items will remain in the history until you remove them manually.

If you’re looking to delete one or two clips, instead of clearing the entire history, you can open the Windows key + V experience, and click the X button for each content you want to delete. Alternatively, you can also click the Clear all button in the history interface to erase the list.

How to use clipboard on Windows 10

Although the new clipboard introduces a new interface and several new features, it’s not an experience complicated to use.

The new clipboard complements the old experience that you already know. Once you upgrade to the October 2018 Update, you can still use the Ctrl + C shortcut to copy and the Ctrl + V shortcut to paste. The same is true using the right-click context menu.

However, you can now use the Windows key + V shortcut to bring up the new clipboard history. In this new interface, you’ll find a list of items (such as text and images) that you have copied from different applications, such as Microsoft Word, Snip & Sketch, OneNote, etc.

If you want to copy and paste content from your history, use these steps:

  1. Select the text or image from an application.
  2. Right-click the selection, and click the Copy or Cut option.
  3. Open the document you want to paste the content.

Use the Windows key + V shortcut to open the clipboard history.

  • Select the content you want to paste.
  • You can also pin the items that you paste frequently for faster access using these steps:

      Use the Windows key + V shortcut to open the clipboard history.

    Click the Pin button for the content you paste frequently.

    When you no longer need the content, click the button again to unpin or the X button to delete the item.

    Using the clipboard history, there are some obvious limitations as no everything you copy will appear in the history or sync across devices. For example, you can copy the name of a file, but copying a file to move it to another location will not appear in the history.

    Also, the cloud clipboard supports images, but only if you copy the image within a document. You cannot copy an image file and expect it to appear in the history or sync across devices.

    Wrapping things up

    Although the new clipboard experience can sync your history across devices, you can only access your history on computers running Windows 10 version 1809 or later and when using the same Microsoft account.

    If you choose to enable this feature, make sure that you also understand the potential security risks. For example, if you’re one of those that usually copy sensitive information (such as passwords, addresses, names, etc.), anything you copy to the clipboard will store in plain text, and anyone with access to your computer will now be able to see this information by just using the Windows key + V shortcut. In addition, if you enable the sync option, you’ll also be uploading your history to the Microsoft servers.

    What do you think about the new clipboard experience on Windows 10? Are you enabling the syncing option too? Let us know in the comments.

    More Windows 10 resources

    For more helpful articles, coverage, and answers to common questions about Windows 10, visit the following resources:

    Halo: MCC’s live service elements make it better, not worse

    Halo: The Master Chief Collection is more popular than ever, but some fans don’t agree with the live service approach 343 Industries has taken with it. Here’s why those elements are, at the end of the day, great for the game and for Halo overall.

    Microsoft’s Surface Duo is not ‘failing up’

    Microsoft announced this week that it was expanding Surface Duo availability to nine new commercial markets. While Surface Duo is undoubtedly a work in progress, this is not a sign of a disaster. It’s also doesn’t mean that Surface Duo is selling a ton either. Instead, the reason for the expansion is a lot more straightforward.

    Here’s what you can do if Windows 10 update KB5001330 is causing issues

    In this guide, we’ll show you the steps to get rid of the update KB5001330 to fix profile, gaming, and BSoD problems with the Windows 10 October 2020 Update and May 2020 Update.

    These are the best PC sticks when you’re on the move

    Instant computer — just add a screen. That’s the general idea behind the ultra-portable PC, but it can be hard to know which one you want. Relax, we have you covered!

    How to copy to clipboard using Access/VBA?

    Using VBA inside Access2003/2007.

    How to copy the contents of a string variable to the clipboard?

    This site recommends a creating a zero length TextBox, copying the string to the TextBox, then running DoCmd.RunCommand acCmdCopy . Ugh. I mean, we may go down the route. But still. Ugh.

    While the MS knowledgebase article shows us how to do it but it involves a number of Windows API calls. Yuk.

    Are those the only two options?

    3 Answers 3

    VB 6 provides a Clipboard object that makes all of this extremely simple and convenient, but unfortunately that’s not available from VBA.

    If it were me, I’d go the API route. There’s no reason to be scared of calling native APIs; the language provides you with the ability to do that for a reason.

    However, a simpler alternative is to use the DataObject class, which is part of the Forms library. I would only recommend going this route if you are already using functionality from the Forms library in your app. Adding a reference to this library only to use the clipboard seems a bit silly.

    For example, to place some text on the clipboard, you could use the following code:

    Or, to copy text from the clipboard into a string variable:

    User Leigh Webber on the social.msdn.microsoft.com site posted VBA code implementing an easy-to-use clipboard interface that uses the Windows API:

    If this link doesn’t go through, search for «A clipboard object for VBA» in the Office Dev Center > Microsoft Office for Developers Forums > Word for Developers section.

    I created the two classes, ran his test cases, and it worked perfectly inside Outlook 2007 SP3 32-bit VBA under Windows 7 64-bit. It will most likely work for Access. Tip: To rename classes, select the class in the VBA ‘Project’ window, then click ‘View’ on the menu bar and click ‘Properties Window’ (or just hit F4).

    With his classes, this is what it takes to copy to/from the clipboard:

    He also provides other functions for manipulating the clipboard.

    Access clipboard in Windows batch file

    Any idea how to access the Windows clipboard using a batch file?

    11 Answers 11

    To set the contents of the clipboard, as Chris Thornton, klaatu, and bunches of others have said, use %windir%\system32\clip.exe .

    Update 2:

    For a quick one-liner, you could do something like this:

    Capture and parse with a for /F loop if needed. This will not execute as quickly as the JScript solution below, but it does have the advantage of simplicity.

    Updated solution:

    Thanks Jonathan for pointing to the capabilities of the mysterious htmlfile COM object for retrieving the clipboard. It is possible to invoke a batch + JScript hybrid to retrieve the contents of the clipboard. In fact, it only takes one line of JScript, and a cscript line to trigger it, and is much faster than the PowerShell / .NET solution offered earlier.

    Old solution:

    It is possible to retrieve clipboard text from the Windows console without any 3rd-party applications by using .NET. If you have powershell installed, you can retrieve the clipboard contents by creating an imaginary textbox and pasting into it. (Source)

    If you don’t have powershell , you can still compile a simple .NET application to dump the clipboard text to the console. Here’s a C# example. (Inspiration)

    Here’s a batch script that combines both methods. If powershell exists within %PATH% , use it. Otherwise, find the C# compiler / linker and build a temporary .NET application. As you can see in the batch script comments, you can capture the clipboard contents using a for /f loop or simply dump them to the console.

    Using the Clipboard

    This section has code samples for the following tasks:

    Implementing the Cut, Copy, and Paste Commands

    This section describes how standard Cut, Copy, and Paste commands are implemented in an application. The example in this section uses these methods to place data on the clipboard using a registered clipboard format, the CF_OWNERDISPLAY format, and the CF_TEXT format. The registered format is used to represent rectangular or elliptical text windows, called labels.

    Selecting Data

    Before information can be copied to the clipboard, the user must select specific information to be copied or cut. An application should provide a means for the user to select information within a document and some kind of visual feedback to indicate selected data.

    Creating an Edit Menu

    An application should load an accelerator table containing the standard keyboard accelerators for the Edit menu commands. The TranslateAccelerator function must be added to the application’s message loop for the accelerators to take effect. For more information about keyboard accelerators, see Keyboard Accelerators.

    Processing the WM_INITMENUPOPUP Message

    Not all clipboard commands are available to the user at any given time. An application should process the WM_INITMENUPOPUP message to enable the menu items for available commands and disable unavailable commands.

    Following is the WM_INITMENUPOPUP case for an application named Label.

    The InitMenu function is defined as follows.

    Processing the WM_COMMAND Message

    To process menu commands, add the WM_COMMAND case to your application’s main window procedure. Following is the WM_COMMAND case for the Label application’s window procedure.

    To carry out the Copy and Cut commands, the window procedure calls the application-defined EditCopy function. For more information, see Copying Information to the Clipboard. To carry out the Paste command, the window procedure calls the application-defined EditPaste function. For more information about the EditPaste function, see Pasting Information from the Clipboard.

    Copying Information to the Clipboard

    In the Label application, the application-defined EditCopy function copies the current selection to the clipboard. This function does the following:

    1. Opens the clipboard by calling the OpenClipboard function.
    2. Empties the clipboard by calling the EmptyClipboard function.
    3. Calls the SetClipboardData function once for each clipboard format the application provides.
    4. Closes the clipboard by calling the CloseClipboard function.

    Depending on the current selection, the EditCopy function either copies a range of text or copies an application-defined structure representing an entire label. The structure, called LABELBOX, is defined as follows.

    Following is the EditCopy function.

    Pasting Information from the Clipboard

    In the Label application, the application-defined EditPaste function pastes the content of the clipboard. This function does the following:

    Opens the clipboard by calling the OpenClipboard function.

    Determines which of the available clipboard formats to retrieve.

    Retrieves the handle to the data in the selected format by calling the GetClipboardData function.

    Inserts a copy of the data into the document.

    The handle returned by GetClipboardData is still owned by the clipboard, so an application must not free it or leave it locked.

    Closes the clipboard by calling the CloseClipboard function.

    If a label is selected and contains an insertion point, the EditPaste function inserts the text from the clipboard at the insertion point. If there is no selection or if a label is selected, the function creates a new label, using the application-defined LABELBOX structure on the clipboard. The LABELBOX structure is placed on the clipboard by using a registered clipboard format.

    The structure, called LABELBOX, is defined as follows.

    Following is the EditPaste function.

    Registering a Clipboard Format

    To register a clipboard format, add a call to the RegisterClipboardFormat function to your application’s instance initialization function, as follows.


    If a window passes a NULL handle to the SetClipboardData function, it must process the WM_RENDERFORMAT and WM_RENDERALLFORMATS messages to render data upon request.

    If a window delays rendering a specific format and then another application requests data in that format, then a WM_RENDERFORMAT message is sent to the window. In addition, if a window delays rendering one or more formats, and if some of those formats remain unrendered when the window is about to be destroyed, then a WM_RENDERALLFORMATS message is sent to the window before its destruction.

    To render a clipboard format, the window procedure should place a non-NULL data handle on the clipboard using the SetClipboardData function. If the window procedure is rendering a format in response to the WM_RENDERFORMAT message, it must not open the clipboard before calling SetClipboardData. But if it is rendering one or more formats in response to the WM_RENDERALLFORMATS message, it must open the clipboard and check that the window still owns the clipboard before calling SetClipboardData, and it must close the clipboard before returning.

    In both cases, the window procedure calls the application-defined RenderFormat function, defined as follows.

    The structure, called LABELBOX, is defined as follows.

    Processing the WM_DESTROYCLIPBOARD Message

    A window can process the WM_DESTROYCLIPBOARD message in order to free any resources that it set aside to support delayed rendering. For example the Label application, when copying a label to the clipboard, allocates a local memory object. It then frees this object in response to the WM_DESTROYCLIPBOARD message, as follows.

    Using the Owner-Display Clipboard Format

    If a window places information on the clipboard by using the CF_OWNERDISPLAY clipboard format, it must do the following:

    Process the WM_PAINTCLIPBOARD message. This message is sent to the clipboard owner when a portion of the clipboard viewer window must be repainted.

    Process the WM_SIZECLIPBOARD message. This message is sent to the clipboard owner when the clipboard viewer window has been resized or its content has changed.

    Typically, a window responds to this message by setting the scroll positions and ranges for the clipboard viewer window. In response to this message, the Label application also updates a SIZE structure for the clipboard viewer window.

    Process the WM_HSCROLLCLIPBOARD and WM_VSCROLLCLIPBOARD messages. These messages are sent to the clipboard owner when a scroll bar event occurs in the clipboard viewer window.

    Process the WM_ASKCBFORMATNAME message. The clipboard viewer window sends this message to an application to retrieve the name of the owner-display format.

    The window procedure for the Label application processes these messages, as follows.

    Monitoring Clipboard Contents

    There are three ways of monitoring changes to the clipboard. The oldest method is to create a clipboard viewer window. WindowsВ 2000 added the ability to query the clipboard sequence number, and WindowsВ Vista added support for clipboard format listeners. Clipboard viewer windows are supported for backward compatibility with earlier versions of Windows. New programs should use clipboard format listeners or the clipboard sequence number.

    Querying the Clipboard Sequence Number

    Each time the contents of the clipboard change, a 32-bit value known as the clipboard sequence number is incremented. A program can retrieve the current clipboard sequence number by calling the GetClipboardSequenceNumber function. By comparing the value returned against a value returned by a previous call to GetClipboardSequenceNumber, a program can determine whether the clipboard contents have changed. This method is more suitable to programs which cache results based on the current clipboard contents and need to know whether the calculations are still valid before using the results from that cache. Note that this is a not a notification method and should not be used in a polling loop. To be notified when clipboard contents change, use a clipboard format listener or a clipboard viewer.

    Creating a Clipboard Format Listener

    A clipboard format listener is a window which has registered to be notified when the contents of the clipboard has changed. This method is recommended over creating a clipboard viewer window because it is simpler to implement and avoids problems if programs fail to maintain the clipboard viewer chain properly or if a window in the clipboard viewer chain stops responding to messages.

    A window registers as a clipboard format listener by calling the AddClipboardFormatListener function. When the contents of the clipboard change, the window is posted a WM_CLIPBOARDUPDATE message. The registration remains valid until the window unregister itself by calling the RemoveClipboardFormatListener function.

    Creating a Clipboard Viewer Window

    A clipboard viewer window displays the current content of the clipboard, and receives messages when the clipboard content changes. To create a clipboard viewer window, your application must do the following:

    • Add the window to the clipboard viewer chain.
    • Process the WM_CHANGECBCHAIN message.
    • Process the WM_DRAWCLIPBOARD message.
    • Remove the window from the clipboard viewer chain before it is destroyed.

    Adding a Window to the Clipboard Viewer Chain

    A window adds itself to the clipboard viewer chain by calling the SetClipboardViewer function. The return value is the handle to the next window in the chain. A window must keep track of this value — for example, by saving it in a static variable named hwndNextViewer.

    The following example adds a window to the clipboard viewer chain in response to the WM_CREATE message.

    Code snippets are shown for the following tasks:

    Processing the WM_CHANGECBCHAIN Message

    A clipboard viewer window receives the WM_CHANGECBCHAIN message when another window is removing itself from the clipboard viewer chain. If the window being removed is the next window in the chain, the window receiving the message must unlink the next window from the chain. Otherwise, this message should be passed to the next window in the chain.

    The following example shows the processing of the WM_CHANGECBCHAIN message.

    Removing a Window from the Clipboard Viewer Chain

    To remove itself from the clipboard viewer chain, a window calls the ChangeClipboardChain function. The following example removes a window from the clipboard viewer chain in response to the WM_DESTROY message.

    Processing the WM_DRAWCLIPBOARD Message

    The WM_DRAWCLIPBOARD message notifies a clipboard viewer window that the content of the clipboard has changed. A window should do the following when processing the WM_DRAWCLIPBOARD message:

    1. Determine which of the available clipboard formats to display.
    2. Retrieve the clipboard data and display it in the window. Or if the clipboard format is CF_OWNERDISPLAY, send a WM_PAINTCLIPBOARD message to the clipboard owner.
    3. Send the message to the next window in the clipboard viewer chain.

    For an example of processing the WM_DRAWCLIPBOARD message, see the example listing in Example of a Clipboard Viewer.

    Example of a Clipboard Viewer

    The following example shows a simple clipboard viewer application.

    Читайте также:  Как быстро переключаться между вкладками windows 10