Jump to content
Sign in to follow this  

Faulty Clipboard Content Following Snippet Expansion

Recommended Posts

I can consistently reproduce an error when I expand a snippet then immediately execute an AppleScript workflow that manipulates the clipboard:


I regularly compose business cards having all the typical information. To help expedite some repetition and reduce errors, I created a snippet and workflow to format email addresses. My defined snippet of ";e" expands to "e-mail " and my workflow is AppleScript to concatenate the first letter of the first name, entire last name, and email domain.


1. I type a person's name (e.g. "John Doe")

2. I select the name and copy it to the clipboard

3. I type the rest of the person's information

4. To enter the person's email address, I expand my snippet to get "e-mail " then execute my workflow (with a key-combo) to process the text-only clipboard and paste the result (e.g. "jdoe@abcdefg.com"). The combination yields the complete result of "e-mail jdoe@abcdefg.com"


This process has worked flawlessly until the most recent update (maybe prior update?). I am currently using v3.3 [801].


My snippets have always expanded each time as expected.

If I copy the name to the clipboard and process it with my workflow, the expected result is pasted.

If I expand my snippet first, then process the clipboard, nothing is pasted. The debug for the workflow shows:


     [ERROR: action.script] 363:376: execution error: Can’t make some data into the expected type. (-1700)


I can reproduce this behavior without fail.



My workflow AppleScript:


set convertedText to words of makeLowerCase(the clipboard)

set the clipboard to text 1 thru 1 of first item of convertedText & second item of convertedText & "@abcdefg.com"


tell application "System Events"

    keystroke "v" using {command down}

end tell


on makeLowerCase(theString)


    set LC to "abcdefghijklmnopqrstuvwxyz"

    set C to characters of theString

    repeat with ch in C

        if ch is in UC then set contents of ch to item (offset of ch in UC) of LC

    end repeat

    return C as string

end makeLowerCase

Share this post

Link to post

@Zork try using "(the clipboard as text)" instead of just "(the clipboard)"


The clipboard contents can contain multiple data items, including rich text, images etc, all within a single clipboard entry. Specifying getting the clipboard as text will ensure you get the plain text version.

Share this post

Link to post

I tried your suggestion, but the workflow fails with same error... I should have reported earlier that when I copy the text, it should already be text only anyway, as I copy from standard web forms in Safari (i.e. no rich text formatting or special Adobe clipboard format, for example). I thought the snippet expansion may be futzing with the clipboard temporarily to expand and restore it to former state... In any case, I noticed this behavior only after updating Alfred recently... Thanks for your help :)

Share this post

Link to post

@Zork I have been playing around with the clipboard after text expansion and am seeing no issues with it.


Instead of getting the clipboard content with AppleScript, have you tried setting the hotkey in your workflow to pass the clipboard content into your workflow? Then you can pass this into the AppleScript.




Set the Argument to "OS X Clipboard Contents".




Share this post

Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this