Lion AppleScripts not working in Mountain Lion?

inaka

macrumors 6502
Original poster
Apr 26, 2010
361
2
Hey all, I purchased and installed ML on the first day it was available, but had to revert back to my Lion clone because it seemed quite a few crucial AppleScripts no longer worked in ML.

A really easy AppleScript that I had to simply speak the name of the sender in AppleMail as a rule no longer worked. I moved the AppleScript into the mail scripts folder, (I think it was "/Library/Scripts/Mail Scripts") but still no dice.

I also had a key automator service what would create a To Do list item in iCal, but that too was broken since, I guess, iCal is now Calendar, etc.

Anyone else have this experience with broken AppleScripts in ML?
 

C64

macrumors 65816
Sep 3, 2008
1,232
219
I'm haven't noticed any problems with AppleScripts in ML. Don't use any in Mail or Calendar though. If I try to add an AppleScript to a new rule in Mail in ML, the default folder is ~/Library/Application Scripts/com.apple.mail. So that's in the user's Library, not the system's Library.
 

inaka

macrumors 6502
Original poster
Apr 26, 2010
361
2
Since I have removed Mountain Lion, I can't check my exact path for scripting and mail rules, but I know it was correct. In fact, if I remember correctly, you can no longer select any path to your AppleScript, and instead it must be in the correct scripts folder (and only there) where you can then select it as a pull-down menu, right?

ML came with some existing mail.app scripts and I made sure my script was in that same folder to be selected, similar to audio sounds as mail alerts, etc.
 

GerritV

macrumors 65816
May 11, 2012
1,179
255
The few Applescripts I made for everyday routines stopped working in ML :mad:
 

inaka

macrumors 6502
Original poster
Apr 26, 2010
361
2
The few Applescripts I made for everyday routines stopped working in ML :mad:
Me too.
It was a deal breaker since I use them all the time. Argh.

Had to go back to Lion because my AppleScript skills aren't good enough to know what's breaking them.
 

Feed Me

macrumors 6502a
Jan 7, 2012
831
6
Location Location
Is it just that these AppleScripts simply don't work in ML or is it that they just need to be tweaked a bit to run on the new operating system? I noticed several of mine don't work any more, too.
 

phobox

macrumors member
Dec 25, 2007
78
0
I run a lot of AppleScripts here as well as various shell scripts and after upgrading to Mountain Lion, everything is working just as well as before. I'd be interested to see the source of the script that no longer works. Im pretty good with AppleScript so I'd be happy to have a look and see if I can fix it for you.
 

inaka

macrumors 6502
Original poster
Apr 26, 2010
361
2
I run a lot of AppleScripts here as well as various shell scripts and after upgrading to Mountain Lion, everything is working just as well as before. I'd be interested to see the source of the script that no longer works. Im pretty good with AppleScript so I'd be happy to have a look and see if I can fix it for you.
Thanks phobox. Maybe you can make heads/tails of this.

Once again, my knowledge of AppleScript is fairly limited, so what I usually do is simply find scripts that people post, and then slightly tweak them for my needs.

Here is my simple AppleScript that I setup as a rule in Mail, and it works great in Lion. This didn't work when I upgraded to ML as mail rule.

It's setup to simply say the name of the sender only:

Code:
on perform_mail_action(info)
	-- see if iTunes is playing
	set itunes_playing to false
	tell application "System Events"
		if (get name of every process) does not contain "iTunes" then
			set itunes_playing to false
		else
			tell application "iTunes"
				if player state is playing then set itunes_playing to true
			end tell
		end if
	end tell
	-- pause iTunes if needed	
	
	if itunes_playing is true then tell application "iTunes" to pause
	
	
	tell application "Mail"
		
		set the_messages to |SelectedMessages| of info
		
		repeat with a_message in the_messages
			
			set the_sender to extract name from sender of a_message
			
			if (junk mail status of a_message) is not true then
				
				say "Mail from " & the_sender
				
			end if
			
		end repeat
		
	end tell
	
	
	-- resume iTunes if it was playing before
	
	if itunes_playing is true then tell application "iTunes" to play
	
end perform_mail_action
Once again, I saved this script in the proper mail scripts folder and directory for ML's version of mail.app, and selected it as a pull-down rule option to play the script on a new mail, but it didn't do anything. Same exact rule works fine in Lion, not ML.

Any info is appreciated, thanks.
 

GerritV

macrumors 65816
May 11, 2012
1,179
255
Thanks for the offer Phobox, but I plan on downgrading for numereous reasons.
 

r4m3y

macrumors newbie
Dec 10, 2009
3
0
I have a version of this same script and it does not work in ML. Very irritating.
 

dmarcoot

macrumors member
Dec 21, 2007
36
0
Me too.
It was a deal breaker since I use them all the time. Argh.

Had to go back to Lion because my AppleScript skills aren't good enough to know what's breaking them.


I have the exact same problme. I kept my speak items script the in the Library/Scripts folder. I place them in the new mail app scripts folder and they no longer work
 

dmarcoot

macrumors member
Dec 21, 2007
36
0
Apple has included some new scripts that speak senders name

look in the system Library folder under Scripts/Mail Scripts

copy them into your user library/Application Scripts/com.Apple.Mail

they work from there. This seems like an error on apples part that mail cant see them in system library.

Im going to compare them to my old scripts to see why they no longer work and these do
 

r4m3y

macrumors newbie
Dec 10, 2009
3
0
Found a working version

After much digging I finally found a version that works. I modified it a little to also speak the Subject. I'm sure the iTunes portion can be added to it also. I found the script here. http://hints.macworld.com/article.php?story=2008012419354669

The only issue I have found so far is if you open mail and more than one message comes in at the same time it reads all of them at the same time.



using terms from application "Mail"
on perform mail action with messages newMessages
repeat with newMessage in newMessages
tell application "Mail"
set senderName to (extract name from sender of newMessage)
set senderSubject to (extract name from subject of newMessage)


say "Mail from " & senderName
say "Regarding" & senderSubject


end tell
end repeat
end perform mail action with messages
end using terms from
 

emporion

macrumors newbie
Sep 5, 2012
1
0
Apple Script Mountain Lion Mail

Had the same annoying experience but found out the following:

While Mountain Lion talks about

/Library/Scripts/Mail Scripts

for the proper location to run a script from within Mail it has to be:

/Library/Application Scripts/com.apple.mail

Saving my former script to this location did the job!

Willem
 

inaka

macrumors 6502
Original poster
Apr 26, 2010
361
2
After much digging I finally found a version that works. I modified it a little to also speak the Subject. I'm sure the iTunes portion can be added to it also. I found the script here. http://hints.macworld.com/article.php?story=2008012419354669

The only issue I have found so far is if you open mail and more than one message comes in at the same time it reads all of them at the same time.



using terms from application "Mail"
on perform mail action with messages newMessages
repeat with newMessage in newMessages
tell application "Mail"
set senderName to (extract name from sender of newMessage)
set senderSubject to (extract name from subject of newMessage)


say "Mail from " & senderName
say "Regarding" & senderSubject


end tell
end repeat
end perform mail action with messages
end using terms from
I'm not sure if Apple changed something, but this script works great for me in testing.

I just got a new Mac with Mountain Lion shipped on it, so there's no turning back for this machine. The script above worked great, and I sent multiple emails to myself as a test and even if I received a few at once, the script spoke each sender separately and not at the same time.

Wanted to say a BIG thanks!

I wonder if Apple maybe corrected this in a Mail.app or OSX update?
 

inaka

macrumors 6502
Original poster
Apr 26, 2010
361
2
Looks like I spoke too soon.

After a really detailed bit of testing, it appears that in Mountain Lion, Applescripts as rules work fine with IMAP accounts, and don't work with POP accounts.

Most frustrating. :(