Im trying to set up a MacOSX application through xcode to send an iMessage. I have an applescript that I have run through Automator to test to make sure it works. However, I want to be able to pass in parameters to the apple script so that it would look like this:
on run(thisContact, thisNumber, thisMessage)
tell application "Messages"
set targetService to 1st service whose service type = iMessage
set targetBuddy to buddy phoneNumber of targetService
repeat thisNumber times
send thisMessage to thisContact
end repeat
end tell
end run
How would I run a script like this from xcode?
Related
I was able to identify the names of some elements to make the click command, but I could not find the name of the element that identifies the accounts.
The idea is to click on an account, copy the token and concatenate it with a password inside the script
Commands already used:
tell application "System Events"
tell process "Authy Desktop"
set visible to true
return every UI element of front window
end tell
end tell
tell application "System Events" to return value of every attribute of window of application process "Authy Desktop"
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
I have an Automator Application containing the action "Show Growl Notification", which is always empty when it appears. I've tried using the "Get Specified Text" and "Get Value Of Variable" actions directly before it, but nothing I've tried seems to work.
The code sample from gadgetmo is almost correct but won't work as is with Growl 1.4
An application must be registered and enabled and must provide a list of notifications it will present and also a list of which of those notifications are enabled.
You can skip all that config stuff if you just hijack the preconfigured automator settings as shown below.
Key points to note are "Automator notification" as the name of the notification and "Automator" as the source application.
tell application "System Events"
set isRunning to (count of (every process whose bundle identifier is "com.Growl.GrowlHelperApp")) > 0
end tell
if isRunning then
tell application id "com.Growl.GrowlHelperApp"
notify with name ¬
"Automator notification" title ¬
"Processing Files" description ¬
input as text application name "Automator"
end tell
end if
Use this in a Run Applescript:
tell application "System Events"
set isRunning to (count of (every process whose bundle identifier is "com.Growl.GrowlHelperApp")) > 0
end tell
if isRunning then
tell application id "com.Growl.GrowlHelperApp"
notify with name ¬
"Test Notification" title ¬
"Test Notification" description ¬
"This is a test AppleScript notification." application name "Growl AppleScript Sample"
end tell
end if
Or download it here.
You can also use this with input.
The action just passes the input through, and doesn't have any text fields that accept variables, so you will need to manually put in the message you want. The Show Growl Notification action (located inside the GrowlHelperApp bundle) does use an AppleScript, so you could modify a copy to do something like use the input if the message field is blank.
I have a Mail rule set up to launch the following applescript:
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
tell application "Mail"
-- do stuff, including...
CheckAddressBook(theName, theAddress)
end tell
end perform mail action with messages
end using terms from
on CheckAddressBook(theName, theAddress)
tell application "Address Book"
-- do stuff
end tell
end CheckAddressBook
Whenever this mail rule executes, it launches address book. Its not activated, but it suddenly shows up on my desktop. My question is, can tell blocks be instructed to launch the application silently, and quit when complete?
AppleScript can't control an application without it running. That's just the way it works. There are other methods you might use to access the Address Book database without launching the application, but if you're using AppleScript to get data from your Address Book database the application has to launch. My recommendation would be to simply add a quit command as suggested by Fábio.
To read the Address Book Database without launching "Address Book.app" I´d suggest to have a look at the command line tool "contacts" available for free here. You would then run it from Applescript like do shell script "/usr/bin/contacts Peter" and handle the values returned.
We are a network of Mac computers. I would like to send email addresses to colleagues with links to files on network locations. I made the following AppleScript:
tell application "Finder"
set uuu to URL of the first item of (get the selection)
set the clipboard to uuu
end tell
which puts the URL of the currently selected file into the clipboard, which can then be pasted into the message (using the Add Link menu item), providing, for example:
file://localhost/Volumes/Commerciale/Clienti/
Unfortunately these links do not work. If I select Go To Folder from the menu item, I can get to the folder using an afp:// type URL.
Is there any way to get this via AppleScript like I do with URL above?
I have solved with this script:
on urlToPOSIXPath(theURL)
return do shell script "python -c \"import urllib, urlparse, sys; print urllib.unquote(urlparse.urlparse(sys.argv[1])[2])\" " & quoted form of theURL
end urlToPOSIXPath
tell application "Finder"
set uuu to URL of the first item of (get the selection)
set pp to my urlToPOSIXPath(uuu)
set the clipboard to "file://" & pp
end tell
Are the volumes already mounted on the email recipients' Mac? Netlink makes a URL that is clickable in Mail. I don't have an AFP share here to test this:
tell application "Finder" to set netlink to URL of (get selection as alias)
Not "automagically" as far as I know. The URL and POSIX path properties only returns the shared directory and not the volume itself. If you use the URL given to you by Applescript, only Applescript can still resolve it. (I get the impression the OS or Applescript is just iterating down the mounted volumes finding the file) You'll need to manipulate the path string to get the format you need.
here is an expanded version of markratledge's post
tell application "Finder" to set netlink to URL of (get selection as alias)
tell application "Mail"
launch
set newMessage to make new outgoing message with properties {subject:"network link", content:netlink, visible:true}
-- Add in code for recipient, etc, etc
--send newMessage
end tell
but that still doesn't seem to work lol