Skip to content

Get data from the clipboard

Power Automate Desktop can send keyboard input as hardware input, so it can reproduce user operations such as copy and paste. By using actions, you can also work with the clipboard directly.

This article explains how to get text data from the clipboard.

The action used here is called “Get clipboard text.”

Details of the “Get clipboard text” action

Section titled “Details of the “Get clipboard text” action”

This action has no input parameters, and the text it gets is stored in the following variable.

Item Value
Variables produced The name of the variable that stores the clipboard text (default: ClipboardText)

action

The flow uses the same clipboard that you normally use, so if you copied any data to the clipboard before the run, that value is what you get.

Be careful when handling sensitive information.

As a sample, I prepared a flow that opens Notepad, types a message, and stores its contents in a variable through the clipboard.

Copy the following code and paste it into the Power Automate Desktop flow designer to add the actions.

System.RunApplication.RunApplicationAndWaitToLoad ApplicationPath: $'''notepad''' WindowStyle: System.ProcessWindowStyle.Normal Timeout: 0 ProcessId=> NotepadProcessId WindowHandle=> WindowHandle
WAIT 1
MouseAndKeyboard.SendKeys.FocusAndSendKeys TextToSend: $'''A test flow is running{Control}(a){Control}(c)''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: False
Clipboard.GetText Text=> ClipboardText
  1. In “Search actions,” type “Get clipboard text.”

  2. Set the produced variable as follows (you can leave the default).

    Item Value
    Variables produced %ClipboardText%
  3. When you run the flow, the clipboard text at that moment is stored in the variable.

The clipboard can hold many kinds of data besides text.

If the clipboard contents can’t be retrieved, the action fails with the error “Can’t retrieve clipboard contents.”

We recommend adding error handling with an “On block error” block.