Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

alC

macrumors newbie
Original poster
Sep 15, 2008
10
0
Hi All,

I'm trying to modify the crazymessagetext for my 8 year old niece, so it opens in TextEdit instead of Mail.

I'm a complete nube on AppleScript and I've tried a heap of things and can't get it to work.

Can anyone help me?

Thanks very much for your time,

Cheers,

Al

Here's the original Apple script
Code:
(*
Crazy Message Text

Copyright © 2002–2012 Apple Inc. All rights reserved.

You may incorporate this Apple sample code into your program(s) without
restriction.  This Apple sample code has been provided "AS IS" and the
responsibility for its operation is yours.  You are not permitted to
redistribute this Apple sample code as "Apple sample code" after having
made changes.  If you're going to redistribute the code, we require
that you make it clear that the code was descended from Apple sample
code, but that you've made changes.
*)

(*
This script takes a string from the user and then makes a new message
where each letter has a different font, size, and color.
*)

property lowFontSize : 36
property highFontSize : 72
property messageText : "Happy Birthday!"

repeat
	set userInput to display dialog "Enter some message text:" & return & return & "Minimum Character Size: " & (lowFontSize as string) & return & "Maximum Character Size: " & (highFontSize as string) default answer messageText buttons {"Cancel", "Set Prefs", "Continue"} default button 3
	
	if the button returned of userInput is "Set Prefs" then
		set minimumFontSize to 9
		
		display dialog "Enter the minimum font size to use:" & return & return & ¬
			"(Must be at least " & (minimumFontSize as string) & ")" default answer lowFontSize buttons {"OK"}
		set newFontSize to text returned of the result as integer
		if newFontSize is greater than or equal to minimumFontSize then
			set lowFontSize to newFontSize
		else
			set lowFontSize to minimumFontSize
		end if
		
		display dialog "Enter the maximum font size to use:" & return & return & ¬
			"(Must be greater than " & (lowFontSize as string) & ")" default answer highFontSize buttons {"OK"}
		set newFontSize to text returned of the result as integer
		if newFontSize is greater than lowFontSize then
			set highFontSize to newFontSize
		else
			set highFontSize to lowFontSize
		end if
		
	else -- button returned of userInput is "Continue"
		set theText to text returned of userInput
		if theText is not "" then
			set messageText to theText
		end if
		exit repeat
	end if
end repeat

set fontList to {"American Typewriter", "American Typewriter Light", "American Typewriter Bold", "American Typewriter Condensed", "American Typewriter Condensed Light", "American Typewriter Condensed Bold", "Arial", "Arial Italic", "Arial Bold", "Arial Bold Italic", "Arial Black", "Baskerville", "Baskerville Italic", "Baskerville SemiBold", "Baskerville Bold", "Baskerville SemiBold Italic", "Baskerville Bold Italic", "Big Caslon Medium", "Comic Sans MS", "Comic Sans MS Bold", "Copperplate", "Copperplate Light", "Copperplate Bold", "Didot", "Didot Italic", "Didot Bold", "Futura Medium", "Futura Medium Italic", "Futura Condensed Medium", "Futura Condensed ExtraBold", "Geneva", "Gill Sans", "Gill Sans Italic", "Gill Sans Light", "Gill Sans Light Italic", "Gill Sans Bold", "Gill Sans Bold Italic", "Herculanum", "Lucida Grande", "Lucida Grande Bold", "Marker Felt Thin", "Marker Felt Wide", "Optima Regular", "Optima Italic", "Optima Bold", "Optima Bold Italic", "Optima ExtraBlack", "Papyrus", "Verdana", "Verdana Italic", "Verdana Bold", "Verdana Bold Italic", "Zapfino"}

tell application "Mail"
	activate
	set crazyTextMessage to make new outgoing message with properties {content:messageText, visible:true}
	
	tell crazyTextMessage
		repeat with eachCharacter in characters
			set font of eachCharacter to (some item of fontList)
			set size of eachCharacter to (random number from lowFontSize to highFontSize)
			set color of eachCharacter to {random number from 0 to 65535, random number from 0 to 65535, random number from 0 to 65535}
		end repeat
	end tell
end tell
 
Last edited by a moderator:
Change this tell block:

Code:
tell application "Mail"
...
...
end tell

with this :

Code:
tell application "TextEdit"
	set crazyTextMessage to make new document with properties {text:messageText}
	tell crazyTextMessage
		repeat with eachCharacter in characters
			set font of eachCharacter to (some item of fontList)
			set size of eachCharacter to (random number from lowFontSize to highFontSize)
			set color of eachCharacter to {random number from 0 to 65535, random number from 0 to 65535, random number from 0 to 65535}
		end repeat
	end tell
end tell
 

Attachments

  • Picture 6.png
    Picture 6.png
    44.3 KB · Views: 98
Thankyou Thankyou Thankyou

Thanks kryten2,

You're going to make an 8 year old girl in Australia delighted after she gets back from School today.

Hope you have a fantastic evening in Belgium

:)

Al
 
The results of your kindness

Hi again,

Just wanted to post a quick pic of what my niece wrote.

I love the mac community and people like you make a difference

thanks again :)

Al

PS I made it into an app with a pic of her favourite toy snuggles as the icon
 

Attachments

  • photo.JPG
    photo.JPG
    565.1 KB · Views: 104
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.