• Skip to primary navigation
  • Skip to main content
Sal Ferrarello
  • About Sal Ferrarello
  • Speaking
  • Connect
    Mastodon GitHub Twitter (deprecated)
You are here: Home / Solution / Alfred Paste Without Clipboard

Alfred Paste Without Clipboard

Last updated on February 9, 2024 by Sal Ferrarello

One of my frustrations with the Alfred App is when I create a custom workflow to paste a string into the current application the old clipboard value is overridden with the new string. What I want is to paste the string in the currently active app, without replacing the content in the clipboard.

Typing in the Current Active App

While I couldn’t find a way for Alfred to paste a string without overwriting the content in the clipboard, I did find I could use Apple Script (osascript) to type the keystrokes in the currently active app. This is almost the same thing.

Alfred Workflow Script to Type Keystrokes

1. Add the “Run Script” Object

When creating your Workflow select Run Script from the Actions section (not the Run NSAppleScript object).

2. Configure the “Run Script” Object

  • Language /usr/bin/osascript (AppleScript)
  • with input as argv
  • running instances Sequentially

and in the Script section put

on run argv
  # Store the incoming {query} into variable "query".
  set query to item 1 of argv

  # Have the system type keystrokes in variable "query".
  tell application "System Events" to keystroke query

  # Pass contents of variable "query" along to next Workflow object.
  return query
end run

Example Workflow

I’ve created a downloadable example Alfred Workflow that uses this technique, Example Alfred Workflow to Type.

Type the Value From a Workflow Variable

In addition to typing the {query} variable, the downloadable example includes a workflow that types the value from an Alfred (in this case {var:myvar}).

The code to do this is

on run argv
  # Have the system type keystrokes in variable "myvar".
  tell application "System Events" to keystroke (system attribute "myvar")

  # Pass contents of {query} along to next Workflow object.
  return item 1 of argv
end run

Limitations

This script simulates typing, rather than doing a paste. This becomes evident when using an editor like Vim, where a paste can occur regarding of the mode you’re in but typing only works when you’re in insert mode. Thus far this is the only place I’ve noticed this limitation.

Related Links

  • Simulate Typing (or Pasting text without copying to clipboard) Alfred Forums
  • Paste text without adding it to clipboard Alfred Forums
  • Paste/Insert text/snippets without using the clipboard in remote desktop (RDP) Alfred Forums
Sal Ferrarello
Sal Ferrarello (@salcode)
Sal is a PHP and JavaScript developer with a focus on the WordPress platform. He is a conference speaker with a background including Piano Player, Radio DJ, Magician/Juggler, Beach Photographer, and High School Math Teacher. Sal can be found professionally at WebDevStudios, where he works as a principal engineer.

Filed Under: Computing, Dev Tips, Solution Tagged With: Alfred

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2026 · Bootstrap4 Genesis on Genesis Framework · WordPress · Log in