RPA / Robocorp

Keyboard / Use clipboard

Paste text from clipboard

tasks.py
Copied!

from robocorp.tasks import task
from robocorp import windows
import pyperclip

@task
def keyboard_paste_from_clipboard():
  # Open Notepad (or other app of your choice)
  desktop = windows.desktop()
  desktop.windows_run("notepad.exe")
  app_window = windows.find_window('subname:"Notepad"')

  # Copy text to the clipboard
  pyperclip.copy("Apollo 11 was a spaceflight conducted by the United States from July 16 to July 24, 1969. It marked the first time in history that humans landed on the Moon. Commander Neil Armstrong and Lunar Module Pilot Buzz Aldrin landed the Apollo Lunar Module Eagle on July 20, 1969, at 20:17 UTC, and Armstrong became the first person to step onto the Moon's surface six hours and 39 minutes later, on July 21 at 02:56 UTC.")

  # Paste text from the clipboard
  app_window.send_keys('{Ctrl}v')