Paste to Text File

This process retrieves the contents of the clipboard and appends them in a text file named “PastedContents.txt”, located in the desktop. If the file does not exist, it is created automatically.

Folder.GetSpecialFolder SpecialFolder:Folder.SpecialFolder.DesktopDirectory \
                        SpecialFolderPath=> DesktopDirectoryPath

Clipboard.GetText Text=> ClipboardText

File.WriteText File: DesktopDirectoryPath+'\PastedContents.txt' \
                TextToWrite: ClipboardText \
                AppendNewLine:True \
                IfFileExists:File.IfFileExists.Append \
                Encoding:File.FileEncoding.Unicode

Display.ShowMessage Title:'Process Completed!' \
                    Message:'Process "Paste to Text File" completed.' \
                    Icon:Display.Icon.None \
                    Buttons:Display.Buttons.OK \
                    DefaultButton:Display.DefaultButton.Button1 \
                    IsTopMost:False \
                    ButtonPressed=> ButtonPressed

In more detail:


The process retrieves the path of the desktop, gets the clipboard text and appends it to the “PastedContents.txt” file. In the end, a message is displayed to inform the user that the process is completed.

Step 1: Retrieve Special Folder

Retrieve the path to the “Desktop” folder.

Folder.GetSpecialFolder SpecialFolder:Folder.SpecialFolder.DesktopDirectory \
                        SpecialFolderPath=> DesktopDirectoryPath

Use the “Folder.GetSpecialFolder” action and store the desktop path in the “DesktopDirectoryPath” output variable.

Step 2: Append Clipboard Text to Text File

Retrieve the clipboard text and append it to the “PastedContents.txt”.

Clipboard.GetText Text=> ClipboardText

File.WriteText File: DesktopDirectoryPath+'\PastedContents.txt' \
                TextToWrite: ClipboardText \
                AppendNewLine:True \
                IfFileExists:File.IfFileExists.Append \
                Encoding:File.FileEncoding.Unicode
  1. Use the “Clipboard.GetText” action.
  2. Use the “File.WriteText”action:
    1. Set the “File” argument to “DesktopDirectoryPath+'\PastedContents.txt'”.
    2. Set the “TextToWrite” argument to “ClipboardText” which is the output variable of the previous action.
    3. Close the conditional block, using the “end” statement.
  3. Change the value of the “IfFileExists” argument from “File.IfFileExists.Overwrite” to “File.IfFileExists.Append”. With this arrangement, if the file exists, the process will append the content to the file instead of overwriting it. If the file does not exist, it will be automatically created.

Step 3: Display a message when the process is completed

Inform the user that the process is completed, by using the “Display.ShowMessage” action.

Display.ShowMessage Title:'Process Completed!' \
                    Message:'Process "Paste to Text File" completed.' \
                    Icon:Display.Icon.None \
                    Buttons:Display.Buttons.OK \
                    DefaultButton:Display.DefaultButton.Button1 \
                    IsTopMost:False \
                    ButtonPressed=> ButtonPressed