Lion-Ready Junk Mail Reporting Scripts

After trying for a day to fix my Lion-broken scripts, I finally gave up and asked folks at Apple’s discussion forum about my problem, and the very first response by Pierre L. nailed it:

Try replacing this one line:

set content to thisMessage’s source

with these two lines:

set theSource to thisMessage’s source
set content to theSource

That worked like a champ.

Updated scripts are available: spam_uce_gov.scpt and spam_paypal_com.scpt. As always, these are provided for free and are unsupported, although I’ll try to help if I can.

[Update, 31 Oct 2011]: These scripts had an issue with background sending, as the accumulated emails would clog up. I got a great suggestion for a fix on the AppleScript forums at apple.com, and now things seem to be working. I’ve replaced the scripts above with the improved copies.

Modifying My On-the-Phone AppleScript – iTunes Status

I’ve made a minor modification to my previous iteration of my on-the-phone AppleScript. Here’s the change:

tell application "iTunes"
	if player state is playing or player state is paused then playpause
end tell

In the previous iteration, running on-phone.scpt would start iTunes to playing if it was invoked while iTunes stopped, and then pause iTunes when re-invoked. That doesn’t make sense: if iTunes is stopped, it’s stopped for a reason, and this script shouldn’t change that fact. For me, iTunes is stopped when I’m using AppleScript to invoke RadioSHARK or Pulsar to listen to the radio.

You can download the updated on-phone script.

Running WordPress 3.0

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….

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:

  1. Mute the system volume so I can focus on the customer.
  2. Pause iTunes.
  3. 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.