Alfred : workflow to simulate keyboard input

26 Jun 2022

Some web applications, especially certain banking applications won’t allow you to copay and paste the text into input forms. In such cases, you might need to enter the text manually or find some way to simulate the keyboard text input.

Using the Alfred app, you can add a custom workflow to simulate text input. This blog explains how you can create a custom workflow.

1. Create a new workflow

You can start by creating a new workflow from Alfred preferences -> Workflows and fill in the basic details about the workflow.

basic details of workflow

2. Add new universal action

Right-click and add new universal action. Please give it a name and choose which types this action should show for. In most cases, you will need only text but feel free to select as per your requirement.

new universal action

3. Add action to run AppleScript

Once the universal action is saved, Again right click and add action to run NSAppleAcript.

add action

This will prompt a new window where you add the following snippet.

on alfred_script(q)
  tell application "System Events" to keystroke q
end alfred_script

fill-action-content

Save it and your workflow is ready. Make sure you enable the workflow before try out.
Please note that this snippet won’t handle the newlines, hence best work for single-line texts.

4. Use the text action with Alfred

Now in Alfred, pick any text from clipboard history or snippet and trigger text actions (Normally right arrow), you can see your new text action.

use workflow via text action

5. Download workflow from GitHub

Alternatively, you can download the workflow from GitHub as well.

If you find my work helpful, You can buy me a coffee.