Get data from the clipboard
Power Automate Desktop allows you to input keyboards as hardware, so you can reproduce operations like copy and paste performed by users, but you can operate the clipboard directly by using actions.
This time, I will explain how to get text data from the clipboard.
Action to use
This time, we use an action called "Get Clipboard Text".
"Get clipboard text" Action details
The action has the following parameters.
Parameter name | value |
---|---|
Generated variables | Variables that store text data on the clipboard |
The clipboard is shared with the user operated, so if you copy some data to the clipboard before execution, the value is referenced.
Be careful when handling confidential information.
Implemented with copy and paste
This time, as a sample, we opened a notepad, entered a message, and prepared a flow to store the content in a variable via a clipboard.
Copy the following code and paste it on the edit screen of Power Automate Desktop to add the target action.
System.RunApplication.RunApplicationAndWaitToLoad ApplicationPath: $'''notepad''' WindowStyle: System.ProcessWindowStyle.Normal Timeout: 0 ProcessId=> NotepadProcessId WindowHandle=> WindowHandle
WAIT 1
MouseAndKeyboard.SendKeys.FocusAndSendKeys TextToSend: $'''Test flow is running {Control}(a){Control}(c)''' DelayBetweenKeystrokes: 10 SendTextAsHardwareKeys: False
Clipboard.GetText Text=> ClipboardText
Operate and implement Power Automate Desktop
Enter "Acquisition of clipboard text" from "Action Search".
Set the parameter as follows
Parameter name value Generated variables %ClipboardText% By execution, the text data of the clipboard at the time of executed is stored in the variable.
Exceptions that can occur
A variety of data is saved on the clipboard besides text.
If the clipboard data is not a format that can be obtained, it may be an error.
We recommend that you implement block processing.