Applescript is a scripting language I haven’t played much with since I got my Powerbook. I actually haven’t found any use of it…until now
I have created a small Applescript which uses the shell “utility” fortune to display some wisdom in the everyday work. From the man page for fortune: «fortune – print a random, hopefully interesting, adage». The following script lets the user loop through random quotes and smart little notes and gives the option to send it to the clipboard:
[code]
repeat
set f_text to (do shell script "/usr/local/bin/fortune -s -n 80
/usr/local/share/fortunes/computers")
display dialog ¬
f_text with icon 1 ¬
with title ¬
"Send Fortune to Clipboard?" buttons {"Cancel", "Next", "OK"} ¬
default button "Next"
if button returned of result is "Cancel" then
display dialog "Cancel"
exit repeat
else if button returned of result is "Next" then
else
set the clipboard to f_text
exit repeat
end if
end repeat
[/code]
*(set f_text to (do shell script “/usr/local/bin/fortune -s -n 80 /usr/local/share/fortunes/computers”) should be one the same line)*
As you can see, I have specified some options for the fortune command. The following bit specifies that the length of the fortunes should not be more than 80 characters:
[code]
-s -n 80
[/code]
-s can be replaced for -l to specify a minimum length instead. The path which I set at the end is the path to computer related cookies.
It is also possible to use this Applescript to set new status/mood messages in iChat/Skype (and possibly other IM applications too, but I have only tested on these). To do this, replace the line which says “set the clipboard to f_text” to:
[code]
tell application "iChat"
set the status message to f_text
end tell
tell application "Skype"
send command "SET PROFILE MOOD_TEXT" & f_text
end tell
[/code]
[tags]applescript, fortune, ichat, skype[/tags]