SteveG Posted December 8, 2020 Share Posted December 8, 2020 Hi, I'm using the following script in a workflow to paste an image into a snippet for an email signature, but all it's pasting is the shared prefix ";" and keyword "emailsignew". set filePath to "/Users/xyz/Documents/folder/emailbanner.jpg" set the clipboard to POSIX file (POSIX path of ((POSIX file (/Users/xyz/Documents/folder/emailbanner.jpg)) as alias)) Any help would be appreciated. Link to comment
deanishe Posted December 8, 2020 Share Posted December 8, 2020 Hi @SteveG, welcome to the forum. 35 minutes ago, SteveG said: Any help would be appreciated. It's really hard to say without having the workflow you're talking about. Could you upload it somewhere (Dropbox?) and post a link? 36 minutes ago, SteveG said: paste an image into a snippet What do you mean? Snippets can't contain images. Link to comment
SteveG Posted December 8, 2020 Author Share Posted December 8, 2020 Hi @deanishe Dropbox link to the workflow (hopefully) https://www.dropbox.com/s/4gx75el028nm9sh/Expand Image.alfredworkflow?dl=0 I'm trying to use the keyword and shared prefix of the workflow in a snippet to kind of call the workflow to paste the image when the snippet runs. Link to comment
deanishe Posted December 8, 2020 Share Posted December 8, 2020 Your workflow works fine for me (after adjusting the image path). Have you tried it in other applications? It looks like an issue with Mail. Link to comment
SteveG Posted December 8, 2020 Author Share Posted December 8, 2020 The workflow itself is just pasting the current contents of the clipboard in other applications, instead of the image. Link to comment
SteveG Posted December 8, 2020 Author Share Posted December 8, 2020 Also, in the snippet that calls the workflow I have the ;emailsig keyword in the middle of the snippet, but that just comes out in plain text as ;emailsig instead of pasting the clipboard contents (which should be the image). Link to comment
deanishe Posted December 8, 2020 Share Posted December 8, 2020 I've had a closer look, and there's an error in your code (which I corrected when changing the image path). You didn't quote the path on the second line. The correct code should be: set filePath to "/Users/stephengreenhalgh/Documents/Guardian/emailbanner.jpg" set the clipboard to POSIX file ((POSIX path of filePath) as alias) You should have been getting an error in Alfred's debugger telling you the code was invalid. Link to comment
SteveG Posted December 9, 2020 Author Share Posted December 9, 2020 Hi @deanishe I thought I had quoted the file path on the second line. You can see that on the original comment of this post. set the clipboard to POSIX file (POSIX path of ((POSIX file (/Users/xyz/Documents/folder/emailbanner.jpg)) as alias)) Link to comment
SteveG Posted December 9, 2020 Author Share Posted December 9, 2020 (edited) I've tried your code second line and mine, and both return the same - in the snippet I use ;emailsignew to call the image which should be on the clipboard and my signature just shows - "Kind regards Steve G ;emailsignew discliamer text." If I type ;emailsignew anywhere I just get the contents of the clipboard, which is never the stored image. Edited December 9, 2020 by SteveG Link to comment
deanishe Posted December 9, 2020 Share Posted December 9, 2020 3 hours ago, SteveG said: You can see that on the original comment of this post. It's in brackets, not quotation marks. String literals must be in quotation marks. 3 hours ago, SteveG said: I've tried your code second line and mine What does the debugger say? The filepath might be incorrect. Link to comment
SteveG Posted December 9, 2020 Author Share Posted December 9, 2020 The debugger doesn't look like it's picking anything up. Is there a way to run it, or does it just highlight errors if there are any? I've copied the file path from finder. I wondered if iCloud was causing an issue and moved the image to my local user folder, but I'm still getting the same issue in that the signature is coming out as - kind regards Steve G ;emailsignew disclaimer. Link to comment
deanishe Posted December 9, 2020 Share Posted December 9, 2020 2 minutes ago, SteveG said: Is there a way to run it, or does it just highlight errors if there are any? Open the debugger, then use the workflow normally. The debugger will show you any log messages or errors from the workflow's scripts. Link to comment
SteveG Posted December 9, 2020 Author Share Posted December 9, 2020 The error must be in the second line because when I type in the workflow keyword and shared prefix it returns the part in quotes set filePath to "/Users/stephengreenhalgh/emailbanner.jpg" set the clipboard to POSIX file ((POSIX path of "/Users/stephengreenhalgh/emailbanner.jpg") as alias) Link to comment
deanishe Posted December 9, 2020 Share Posted December 9, 2020 What do you mean "returns"? If you're writing the full image path in the second line of the script, you don't need the first line at all: it's setting a variable that's never used. Link to comment
SteveG Posted December 9, 2020 Author Share Posted December 9, 2020 I'm getting the following error from the debugger - [14:17:08.247] ERROR: Expand Image[Run Script] /Users/stephengreenhalgh/Library/Caches/com.runningwithcrayons.Alfred/Workflow Scripts/ED03D6FF-F57C-4974-8F9D-A59D80E7E5C7:156:161: execution error: Can’t make "/Users/stephengreenhalgh/emailbanner.jpg" into type alias. (-1700) Link to comment
deanishe Posted December 9, 2020 Share Posted December 9, 2020 Are you sure that file exists? Try this: set the clipboard to (POSIX file "/Users/stephengreenhalgh/emailbanner.jpg") Link to comment
SteveG Posted December 10, 2020 Author Share Posted December 10, 2020 Lol, yes I'm sure the file exists. I've tried that and it runs without errors in the debugger, but doesn't paste the image in mail. It does work in other apps though, so unless it's fixed in either an Apple or Alfred update I guess it just won't work. With regards to running a snippet that calls the image paste workflow, I've never managed to get that to paste the clipboard. When I say "returns" I mean that the snippet calls the workflow because I'm using ;emailsignew in the snippet, but it just shows the text ";emailsignew" instead of pasting the clipboard. Link to comment
deanishe Posted December 10, 2020 Share Posted December 10, 2020 1 hour ago, SteveG said: Lol, yes I'm sure the file exists. Your workflow works for me. The only thing I had to change was the path. So it's the obvious place to double-check. 1 hour ago, SteveG said: It does work in other apps though Well there's your clue that the problem is at Mail's end. Have you checked that Alfred has all necessary permissions? Other than that, you can try adding delays to the script. Increasing the "Restore after" period in Alfred Preferences > Features > Snippts > Auto Expansion Options often helps when snippets aren't working in a particular application. You could also try adding delay 0.5 to the top of your AppleScript to give Alfred time to clear the snippet trigger from Mail. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now