Archive for category Automation
Quit All Applications
Posted by clark in Applescript, Automation on 2010/04/01
Over at the Applescript Blog there’s a nice little post on how to quit all running applications. I thought I’d put up the python equivalent. Read the rest of this entry »
Displaying a SalesForce Contact’s Emails in Mail
Posted by clark in Applescript, Automation, Mail, Python, SalesForce on 2010/02/23
SalesForce has a nice way of keeping track of emails from within SalesForce. But it tends to presume you do all your emailing from within Salesforce or use a program (like Maildrop) to sync your email from Apple’s Mail with SalesForce. This really isn’t terribly convenient. I do all my emailing from within Mail itself.
When I’m looking at a lead or contact though it would be nice to see a list of all our emails back and forth at a glance. The following script does that by creating a smart mailbox for the email address of the currently viewed lead or contact.
While I wrote this to access SalesForce it would be trivial to modify this to use a different source, such as Address Book.
Limits with Applescript and Mail
Posted by clark in Applescript, Automation, Mail on 2010/02/22
So I spent a big chunk of Friday night trying to write a script that would bring up emails for the current lead I was looking at in SalesForce. However I quickly ran up against some pretty serious limits in Mail’s Applescript support. Specifically there isn’t scripting of Smart Mailboxes (which are really just saved Spotlight searches).
Now you can try and hack around this using mdfind from the shell. You’ll be able to find the actual email files and tell Mail to open them. They’ll open fine. You’ll think that you can then get the relevant information from them so you can create a useful list. However you’ll then discover the Mail offers no way to get the message associated with a window.
This is a real big limit. Ideally what you would want to do is create and select smart mailboxes on the fly.
Address Book to Sales Force
Posted by clark in Address Book, Applescript, Automation, Python, SalesForce on 2010/02/06
Here’s an other little script I wrote for using SalesForce.com. We take the selected contacts in Address Book, open up a new contact entry in SalesForce and then fill in the data. Now I could have made this a bit more advanced, copying in all the emails, addresses, phone numbers and so forth that are possible. But I rarely use those. So I can handle copying and pasting those or just modifying the script if they become more common.
Once again Apple’s optional develop menu in Safari is invaluable. I used to do all this with plugins for FireFox but I now actually prefer analyzing web pages in Safari. All you have to do is find the form name and then the id of the field you want to fill in. You then use JavaScript in Safari to set the value like this:
Safari.do_JavaScript("document.forms['form_name']['field_id'].value = \"" + myvalue + "\"", in_=FEdoc)
I’ve used this technique a lot in various scripts. So long as there aren’t logic bugs on the page (i.e. using an identical id multiple times) this approach works fantastic and is a rapid way to fill in forms.
SalesForce to FedEx
Posted by clark in Applescript, Automation, Automator, Python, SalesForce on 2010/02/06
A lot of my scripts are designed to make shipping easier. I usually use FedEx for my shipping and have discussed in the past filling out the packing forms in Safari in an automated way. I don’t know about you, but this saves me a lot of time. I’ve been using SalesForce a lot of late and one thing I do frequently is ship samples to leads or to existing contacts. Since I don’t (yet) have a safe syncing between my leads and Address Book I wanted a way to use a Service to print a FedEx packing slip for the displayed contact or lead.
This script makes a few assumptions. First it assumes you are logged into FedEx. (If you have an open window in Safari somewhere that’s sufficient) It then assumes the front window is your SalesForce window. It does check to ensure you are in a detail. If you’re not then it doesn’t do anything.
Script Storage
Posted by clark in Automation, Blog on 2010/02/02
I get a lot of Google searches which land on various scripts. Unfortunately the landing locations are often blog posts from months ago. Sometimes these are outdated or even non-functioning scripts. (Many were written before Snow Leopard) To try and let people know about the latest versions I’m putting up a Script page which will contain the latest versions of my various scripts. (See the tab near the top of the page)
I’m also using this as an excuse to clean up a lot of scripts. In many cases they use older Python classes that have been depreciated. In some cases they no longer work with Snow Leopard.
The first script I’ve added is my script to look up all addresses in my address book within a specified distance. I’ve modified it so it prompts with a dialog box for the address and only looks up addresses in my group “Clients” rather than all people. (I use this for when someone sends an email to me asking for nearby stores that stock our chocolate) I have this configured as a service using Automator. So it’s easy to access. It generates a nicely formatted list in either TextMate or Automator for pasting into a mail message.
Sending Data to Windows
Posted by clark in Applescript, Automation, System on 2010/01/22
For reasons I won’t go into I had to get some data imported into a popular Window app. Sadly the app doesn’t have good import abilities. Were I a com hacker I might have been able to do something on Windows. However I’m primarily a Mac guy and all my data was in an Excel spreadsheet. Enter the hack of Python, GUI scripting and appscript. I had my Windows program open in Parallels.
Here’s a nice little template I used for this. Some of it might have been handled better using cut and paste. But for reasons I won’t go into I wanted it to appear to the Windows app as if I were typing all the data from my Excel spreadsheet into the Windows app.
I suspect this may come in handy for a few of you who run OSX and Windows simultaneously and need to be able to have some level of scripting in Windows. What’s nice about Windows (and sometimes frustrating about Macs) is that you can do almost all things via the keyboard. This means utilizing Applescript/Appscript you can script a lot in Windows from the Mac.
Salesforce and the Mac
Posted by clark in Address Book, Automation, SalesForce, iCal on 2010/01/21
I just started using Salesforce for CRM. I’ll probably have some posts on automating stuff with SalesForce over the next few weeks..
One thing I already found is an open source Mac sync that looks quite useful. It syncs contacts, events and tasks from Address Book and iCal to Salesforce. What I’m not sure about is custom fields. However there is source. (And this might be a great way to delve into Cocoa) There’s also Maildrop for quickly associating mail in Mail or Entourage with contacts in Salesforce.
Salesforce appears to have a nice API so I might be able to put together some useful Python scripts. There’s actually a Python discussion board at Salesforce. So I should be having a lot of fun the next month or so getting this setup for our company.
Man Pages in Preview and Textmate
Posted by clark in Automation, TextMate on 2009/12/23
Someone put up a nice Bash script to view man pages in Preview. The one downside is it’s a tad slow and only really gives you bold text.
I tend to use the following more:
Handling Difficult Printing
Posted by clark in Applescript, Automation, Productivity on 2009/11/12
So I had to print a large number of labels today. (By large I mean about 500 pages worth) The problem is, as some of you undoubtedly know, for the really good labels they are thick and you can’t print too fast. Otherwise they don’t feed through laser printers properly. (They stick together, lose their position, etc.)
If you have this problem, here’s an easy script.
.jpg)
Recent Comments