Send GIF from iMessage by AppleScript - applescript

I know text message can be sent from AppleScript by "tell application 'Messages'", but if there is a method to send GIF by any AppleScript?
Many thanks...

use application "Messages"
set gif to POSIX file "/Users/CK/Pictures/giphy.gif"
set [him] to buddies of service "E:someone#me.com" whose handle is "something"
send the gif to him

Related

Apple Mail and Applescript

I have has this script working fine on Outlook 2011 for Mac all on a local machine.
I have now found out my "rules" will now work on Apple mail after all these years.
The last part of the rule is to run this script which then sends an HTML email back to the sender.
If I change the tell application "Microsoft Outlook" to tell the application "Mail", I keep getting Syntax Errors and it highlights the "mail folder" telling me it is wrong.
I am stumped.
I am using Exchange with the Mail app. Not sure if that may be the issue?
tell application "Microsoft Outlook"
set replyToMessage to message 1 of mail folder "•HOT FOLDER•"
if (replyToMessage is "") then
log ("NOTHING SELECTED!")
return
end if
set replyMessageSubj to subject of replyToMessage
set replyMessage to reply to replyToMessage without opening window
set contentHTML to "Vault:Users:vault:Documents:VAULT:Digital_Subscription_Reply:Digital_issue22.html" as alias
set contentHTML to read contentHTML
set the content of replyMessage to contentHTML
set the subject of replyMessage to "Vault Digital Issue - Issue 22"
send replyMessage
end tell
Every scriptable application has its own scripting dictionary with its own unique terminology. We can't just change tell application "Microsoft Outlook" to tell application "Mail" and expect it to work, because Mail and Outlook use different keywords for their equivalent objects. I don't have outlook installed on my machine, so I can't compile or run the original script, but I've modified it as best I can to use Mail terminology. No guarantee this will work, but it will compile and run so you can (at least) test it.
tell application "Mail"
set replyToMessage to message 1 of mailbox "•HOT FOLDER•"
if (replyToMessage is "") then
log ("NOTHING SELECTED!")
return
end if
set replyMessageSubj to subject of replyToMessage
set replyMessage to reply replyToMessage without opening window
set contentHTML to "Vault:Users:vault:Documents:VAULT:Digital_Subscription_Reply:Digital_issue22.html" as alias
set contentHTML to read contentHTML
set the content of replyMessage to contentHTML
set the subject of replyMessage to "Vault Digital Issue - Issue 22"
send replyMessage
end tell
When you're in Script Editor, select "Open Dictionary..." from the File menu and scroll down to open the Mail scripting dictionary. That will give you all the relevant terminology for scripting Mail.app.

how to get the subject of my outlook email to mac clipboard through an applescript?

I am new to applescript. I am trying to get the subject of the selected outlook (2011) email with the following applescript.
tell application "Microsoft Outlook"
set theMessage to the current messages
get the subject of theMessage
end tell
But I am getting the following error message.
Can’t get subject of {incoming message id 392990 of application "Microsoft Outlook"}
Can someone please help me?
I am completely new to AppleScript ... and am wanting a script to extract a list of both the the 'subject line' and 'date received' from a specific batch of emails in Outlook 2011.
Is this possible.
The script above works great for extracting the subject line from one highlighted email.
Many thanks
Simon
The reason this does not work is that set theMessage to the current messages returns a list. Notice the { }
tell application "Microsoft Outlook"
set theMessage to first item of (get current messages)
set theSubject to the subject of theMessage
end tell
set the clipboard to theSubject

Getting Mac Hazel to e-mail .lnk, doc, and .xls files to my evernote account

i'm trying to automate and simplify my life. I'm new to hazel and apple scripts..
I have a lot of documents and i pull a lot of things of the web. i simply drag the link to my desktop where it makes a .lnk file.
i want to create a hazel + apple script that will look for these .lnk files and send an email with the link file attached to my evernote email address.
Any suggestions would be appreciated.
In Hazel Create a new rule.
If all ..
1, Extension - is - ink
Do the following:
2, Run AppleScript - embedded script.
Click the info icon to edit the script. Paste this script into it. With the correct email addresses, subject, content set.
set theAttachment1 to (POSIX path of theFile)
set subject_ to "subject"
set the_content to "the_content"
tell application "Mail"
set newMessage to make new outgoing message with properties {subject:subject_, content:the_content & return & return}
tell newMessage
set visible to false
set sender to "my1#mac.com"
make new to recipient at end of to recipients with properties {address:"their#mac.com"}
make new attachment with properties {file name:theAttachment1} at after the last paragraph
(* change save to send to send*)
send --<<<<---------------- change save to send to send or send to save to save to drafts
(* change save to send to send*)
end tell
end tell
3, Add a second action to move the file to a folder. If not you may keep getting the same files sent over and over again.

How to find the default mail client on Mac OS X?

I've an application which gives Images as outputs and those outputs are to be opened in a mail client's new message [as an attachment].
On Mac OS X, Apple mail is the default mail client. So what I did was, wrote an automator workflow and opened the output in Mail.app using 'Open Finder Items' action.
Here is my problem:
If user has configured the 'Microsoft Entourage' or 'ThunderBird' or any other mail clients as their default mail client then my automator action cannot open the output in their configured mailing app.
I got some idea to find and launch the default mailing application in this link.
How do I get the default mail client using applescript?
can anyone help me how can I attach my output images to a new mail message of the launched mail client?
For the record, the accepted answer in the linked question was something like this:
tell application "System Events"
try
value of property list item "LSHandlerRoleAll" of (property list item 1 of property list item "LSHandlers" of property list file (path to preferences as text) & "com.apple.LaunchServices.plist" where value of property list items contains "mailto")
on error
"com.apple.mail"
end try
end tell
You could also use MMac::InternetConfig:
VERSIONER_PERL_PREFER_32_BIT=1 perl -MMac::InternetConfig -le 'print +(GetICHelper "mailto")[1]'
or DefaultApplication:
$ ~/bin/DefaultApplication -url mailto:
/Applications/Mail.app

Send a key code to an application without activating it first?

I'm trying to send the spacebar key to an application without activating it first. The following code almost does what I want but it brings the application to the foreground first.
tell application "X"
activate
tell application "System Events" to key code 49
end tell
I don't think you can send a keystroke to an inactive application, but you can hide an app immediately after activating it and executing code for it. This does however, cause the app to briefly flash before it hides.
tell application "System Events"
tell application "X" to activate
key code 49
set visible of process "X" to false
end tell
Sending a keystroke can basically be seen as using a keyboard, but the only difference is that the keys that need to be pressed are already predefined. The rest of the process revolving around this doesn't change. This means that the application itself still needs to be opened and activated before you can actually send keystrokes to it.
Depending on the application however, it might be possible to use certain Applescript functions in the application's API to send different inputs to the application without having to activate it first. Take the Messages API for instance:
tell application "Messages"
set theBuddy to buddy "someone#mac.com" of service "iMessage"
send "Hi there" to theBuddy
end tell
How about deactivating it afterwards?
activate application "X"
tell application "System Events" to key code 49
activate me
Position is offscreen to prevent it from flashing where the user can see it or reduce its opacity.
There are courses of investigation.
If the application is one you have developed yourself you have the following options:
*simply have a public property exposed and set that to the key you want to send it.
*have your application polling a folder for a file and you send your instructions via that.
With a windows API hook of some type you can get control of the application without activating it. I am pretty certain if I put my mind to it I could take control of anything on the computer.
In simple terms think out of the box, it does not necessarily need to be a key press you send, you just want to instruct it to do something. There is loads of options Interface Marshalling, Interops, OLE, DDE, looks like I have turned up on this site just in time!

Resources