I’ve upgraded this site to WordPress 3.0 as a pathfinder for a number of reasons, one of them being that I have a professional interest in doing so. This site is always my bleeding edge for WordPress upgrades—if it doesn’t break here, it typically won’t break elsewhere….
Monthly Archives: June 2010
Developing an On-the-Phone AppleScript
I’m now working from home, but I can’t stand not having music going when I’m working. I often answer the phones, so it was important to me to have an AppleScript that would quickly do the following:
- Mute the system volume so I can focus on the customer.
- Pause iTunes.
- Setting my Adium status as On-the-Phone so my co-workers know I’m on the phone.
The fun thing is that I’ve got to get the script to do the reverse when invoked again. Otherwise, what use is it?
My first step was to use Leaf Raker’s suggestion for how to mute the system volume with AppleScript. The approach there works fine; the only issue is going to be that the system volume returns to 50 when it’s invoked a second time. If you’re always using this script during the day, though, that shouldn’t be a problem. Thanks, Leaf Raker, for getting me started!
The second step is pausing iTunes. If you read the iTunes Applescript Dictionary, you’ll see that it has a verb “playpause” that toggles the status of iTunes. This is helpful for me when I’m listening to a podcast while working, because I would like to not lose my place while I’m on the phone. So it’s tell application "iTunes" to playpause to make it happen.
The last step, of course, is the Adium status change. The Adium wiki has a page on their AppleScript support, and after a number of tests, I found that this worked:
tell application "Adium" set thisStatus to the status type of the first account if thisStatus is available then set the status type of the first account to away set the status message of the first account to "I'm on the phone; be with you shortly" else set the status type of the first account to available set the status message of the first account to "" end if end tell
Now, this only works for my setup because I have the one account in Adium on this machine—Adium, for me, is dedicated to the IM support I have with work. Multiple-account setups would take some sniffing; this is done with of account "somename", rather than “the first account”. Of course, if you’re in my situation—working from home, wanting to set your status away when you’re on the phone—you probably only have one account in Adium that needs toggling. [You better not be on multiple IM channels if you're telecommuting, or you won't get anything done!]
The whole script is as follows:
set curVol to (get (output volume of (get volume settings))) if curVol > 0 then set volume output volume 0 else set volume output volume 50 end if tell application "iTunes" to playpause tell application "Adium" set thisStatus to the status type of the first account if thisStatus is available then set the status type of the first account to away set the status message of the first account to "I'm on the phone; be with you shortly" else set the status type of the first account to available set the status message of the first account to "" end if end tell
You can also download this: on-phone.scpt.
As always: shared without license and support. I’ll help if you ask questions in the comment, but I am under no obligation to get you to done. I worked to figure this one out, so you can work, too.
Unlike with my Mail scripting, I invoke this with the excellent Launchbar, although I’m sure that Quicksilver will invoke it for you, too. I just put this in ~/Library/Scripts for safe-keeping.
Update to my Spam-Reporting AppleScripts
I think I tried to do this back when I set these spam-reporting AppleScripts up originally, but I couldn’t find the right variable to set. Turns out I didn’t look hard enough. Here’s the change:
tell application "Mail"
set theMessages to the selection
repeat with thisMessage in theMessages
set newMessage to make new outgoing message at end of outgoing messages
tell newMessage
set content to thisMessage's source
set subject to thisMessage's subject
make new to recipient with properties {address:"spam@uce.gov"}
end tell
send newMessage
set junk mail status of thisMessage to true
set read status of thisMessage to true
move thisMessage to mailbox "INBOX/ConfirmedJunk" of account "[$account]"
end repeat
end tell
Simple enough, no? The updated scripts: spam_uce_gov.scpt and spoof_paypal_com.scpt. You could, of course, further modify the {address:”email@email.tld”} to send wherever you like. If, for example, you have a specific place you’re fighting phishing attempts [e.g., your bank], and you know their phishing address, set one up for them.
Additional Thoughts
I use these two scripts with the excellent Mail Act-On package. I have rules for each: J for general junk mail, and P for PayPal/eBay spam. Actually, my MA-O use is what drove me to seek out the junk mail status flag, because otherwise to train Mail’s spam filter took an extra step. I wish I’d Googled a little harder three years ago, as I’d probably have saved myself an hour of typing and clicking over that time.
Update: These scripts were broken by syntax changes in OS X Lion, but they have been updated.