RobRoyce Posted October 22, 2018 Posted October 22, 2018 (edited) This is my first AppleScript workflow, I've spent almost two days trying to figure out what I'm doing wrong. Basically the alfred command is "text [name] [message] and it will send a message to the number associated with [name]. So far, I haven't incorporated Contacts into it, so the friend names are hard coded (friend1, friend2, etc changed in the code below for privacy). It works so far as basic functionality goes, but it's doing this really weird thing and I don't understand why. Basically, the punctuation marks (!@#%&*(),.?/"') are completely removed from the message, but ($ and ^) are fine for some reason. I tried escaping the characters with \, /, " ", and ' ', but none of those work. Can anyone point me in the right direction? on alfred_script(q) --Save original applescript delimiter set saveTID to text item delimiters --Set new delimiter set text item delimiters to " " set buddyNumber to "+0" --Get name set buddyName to first word of q as text --Get message set buddyMessage to words 2 thru end in q as text log "name: " & buddyName log "message: " & buddyMessage if (buddyName) is "friend1" then set buddyNumber to "+18880009999" else if (buddyName) is "friend2" then set buddyNumber to "+19998880000" else if (buddyName) is "friend3" then set buddyNumber to "+10009998888" end if log "number: " & buddyNumber tell application "Messages" set targetBuddy to buddyNumber set targetService to id of first service whose service type = iMessage set textMessage to buddyMessage set theBuddy to buddy targetBuddy of service id targetService send textMessage to theBuddy end tell --Reset delimiter set text item delimiters to saveTID end alfred_script Edit: I'm an idiot for not reading the post instructions on the sticky. Here's the workflow, but you'll need to replace the fake numbers with ones that actually work (I use my own number for testing). Also, you need to have an active conversation in iMessages with the person you are trying to text, else it will simply open iMessage and do nothing. Alfred Version: 3.7 MacOS 10.14 Mojave Text Message Workflow Edited October 22, 2018 by RobRoyce Added more info
RobRoyce Posted October 22, 2018 Author Posted October 22, 2018 I guess I solved my own problem, turns out AppleScript doesn't include punctuation marks in the "word" category. I changed all instances of "word" to "text item" and it worked perfectly!
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