sepulchra Posted April 1, 2023 Posted April 1, 2023 (edited) I've built a contact action to send contacts messages without opening messages, but for some reason if I use an emoji the emoji is turned into unicode (i think) characters.   This is what the text should look like: "🤚testing:, but when using my workflow it comes out like this: "ü§ötesting"   here is my workflow:       When I don't use a variables and just put a number directly into the script and pass the message as a {query} the script it will pass the emoji. Are arg/vars not capable or passing emojis or images?       Edited April 1, 2023 by sepulchra
Stephen_C Posted April 1, 2023 Posted April 1, 2023 Quote Are arg/vars not capable or passing emojis or images?  I have two workflows that send text to Messages and both can send emojis. Sorry that I've not had a chance to revise the script to achieve exactly what you're doing but what I use is this:  on run argv repeat with i from 1 to number of items in argv set textMessage to item i of argv tell application "Messages" set targetFriend to "xxxxxxxxxxx" set targetService to (id of 1st account whose service type = iMessage) set theFriend to participant targetFriend of account id targetService send textMessage to theFriend end tell end repeat tell application "Messages" quit end tell end run  In my case the number is preset in the script but I imagine it's relatively easy to send the second argument as the telephone number of targetFriend.  As that works with emojis I'm wondering if the difference in coding may potentially be the solution.  (By way of further explanation my workflow simply uses a keyword to send what then follows as a message to the preset recipient.)  Stephen
sepulchra Posted April 1, 2023 Author Posted April 1, 2023 (edited) What is the repeat step doing? the repeat i from 1 etc  And what is confusing to me is that the only difference in my workflows is the use of the arg/vars alfred objects. the one without the objects like yours also sends emojis. I'm puzzled.   Edited April 1, 2023 by sepulchra
Stephen_C Posted April 1, 2023 Posted April 1, 2023 17 minutes ago, sepulchra said: What is the repeat step doing? the repeat i from 1 etc Nothing at present, as there's only one argument. This was a very early workflow/script that I wrote and I've resolved to update it tomorrow (when I have more time) to make more sense of it. I'll experiment a little tomorrow and see if I can get something more along the lines of your script working.  I've certainly succeeded in passing arguments to Messages (for recipient and message) using an Open URL action with the URL in the following form  imessage://{var:recipient}&body={var:theMessage}  and that will send emojis.  (Sorry for these hasty replies: not much time just now!)  Stephen
sepulchra Posted April 1, 2023 Author Posted April 1, 2023 (edited) Thanks. i'll keep exploring in the meantime. Edited April 1, 2023 by sepulchra
vitor Posted April 1, 2023 Posted April 1, 2023 This may be due to AppleScript’s specific handling of unicode. Does the same happen if the code is written in /usr/bin/osascript (JavaScript)? Alternatively, it may be a case of NSTask decomposition. What happens if you save your script and run it from a terminal, is the emit correctly sent?
sepulchra Posted April 1, 2023 Author Posted April 1, 2023 (edited) this is where you have reached my limitations.... i'm not sure how to rewrite in javascript or run from terminal but happy to try with some help but please put this low on your priority list! Edited April 1, 2023 by sepulchra
Stephen_C Posted April 2, 2023 Posted April 2, 2023 Sorry for the hasty and less than helpful responses yesterday! I've now been able to do some more work and can confirm the result you discovered with your first workflow variant. I see exactly the same problem with emojis when using that form of workflow.  As a result I prefer to use this workflow:   The script is as follows:  on run argv set targetFriend to item 1 of argv set textMessage to item 2 of argv tell application "Messages" set targetService to (id of 1st account whose service type = iMessage) set theFriend to participant targetFriend of account id targetService send textMessage to theFriend end tell tell application "Messages" quit end tell end run  Obviously there are some differences between what you did and what I have done: I have a list filter listing various friends' numbers. At the end of my script I've added a quit command to Messages to emulate what you were trying to do (i.e., send messages without opening Messages)—but I find the end result very similar to yours. I hope this is a rather more helpful than yesterday's posts. 😀  Stephen sepulchra 1
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