hey, I’m trying to make something like whats on the movie ‘Iron Man’ where the computer says the date, time and weather. I got the date and time down, but not the weather, and my current script downloads and displays the current weather map, it also minimizes everything to the dock to keep the desktop open.
here is the code:
tell application "Thunderbird" to activate
delay (10)
(*Download, save to desktop, and open current weather map*)
set weather_map to "acttemp_720x486.jpg" -- temperatures
set the target_URL to "http://maps.weather.com/images/maps/current/" & weather_map
set the destination_file to ((path to desktop as string) & "weathermap.jpg")
tell application "URL Access Scripting"
download target_URL to file destination_file replacing yes
end tell
tell application "Finder" to open alias destination_file
delay (10)
(*Say the Date*)
set myDate to get (current date)
set myMonth to get month of (current date)
set myDay to get day of (current date)
set myYear to get year of (current date)
if myDay is 1 then
say ("Today is: " & myMonth & " 1st - " & myYear & "!")
else if myDay is 2 then
say ("Today is: " & myMonth & " 2nd - " & myYear & "!")
else if myDay is 3 then
say ("Today is: " & myMonth & " 3rd - " & myYear & "!")
else if myDay is greater than 3 then
say ("Today is: " & myMonth & " " & myDay & "th- " & myYear & "! ")
else if myDay is 31 then
say ("Today is: " & myMonth & " 31st " & myYear & "!")
else if myDay is 21 then
say ("Today is: " & myMonth & " 21st " & myYear & "!")
else if myDay is 22 then
say ("Today is: " & myMonth & " 22nd " & myYear & "!")
else if myDay is 23 then
say ("Today is: " & myMonth & " 23rd " & myYear & "!")
else
say ("There is something wrong with the applescript")
end if
delay (5)
(* minimize everything *)
tell application "System Events"
set theButtons to {}
repeat with theApplication in application processes
repeat with theWindow in windows of theApplication
repeat with theButton in buttons of theWindow
if ((description of theButton) is "minimize button") then
set theButtons to theButtons & {theButton}
end if
end repeat
end repeat
end repeat
repeat with theButton in theButtons
click theButton
end repeat
--do it twice because it usually misses one the first time
repeat with theButton in theButtons
click theButton
end repeat
end tell
delay (4)
(*say the current time*)
set myHour to get hours of (current date)
set myMinute to get minutes of (current date)
if myHour is 1 then
say ("it is now one-" & myMinute & " -A-M!")
else if myHour is 2 then
say ("it is now two-" & myMinute & " -A-M!")
else if myHour is 3 then
say ("it is now three-" & myMinute & " -A-M!")
else if myHour is 4 then
say ("it is now four-" & myMinute & " -A-M!")
else if myHour is 5 then
say ("it is now five-" & myMinute & " -A-M!")
else if myHour is 6 then
say ("it is now six-" & myMinute & " -A-M!")
else if myHour is 7 then
say ("it is now seven-" & myMinute & " -A-M!")
else if myHour is 8 then
say ("it is now eight-" & myMinute & " -A-M!")
else if myHour is 9 then
say ("it is now nine-" & myMinute & " -A-M!")
else if myHour is 10 then
say ("it is now ten-" & myMinute & " -A-M!")
else if myHour is 11 then
say ("it is now eleven-" & myMinute & " -A-M!")
else if myHour is 12 then
say ("it is now twelve-" & myMinute & " -PM!")
else if myHour is 13 then
say ("it is now one-" & myMinute & "-PM!")
else if myHour is 14 then
say ("it is now two-" & myMinute & "-PM!")
else if myHour is 15 then
say ("it is now three-" & myMinute & "-PM!")
else if myHour is 16 then
say ("it is now four-" & myMinute & "-PM!")
else if myHour is 17 then
say ("it is now five-" & myMinute & "-PM!")
else if myHour is 18 then
say ("it is now six-" & myMinute & "-PM!")
else if myHour is 19 then
say ("it is now seven-" & myMinute & "-PM!")
else if myHour is 20 then
say ("it is now eight-" & myMinute & "-PM!")
else if myHour is 21 then
say ("it is now nine-" & myMinute & "-PM!")
else if myHour is 22 then
say ("it is now ten-" & myMinute & "-PM!")
else if myHour is 23 then
say ("it is now eleven-" & myMinute & "-PM!")
else if myHour is 0 then
say ("it is now twelve-" & myMinute & "-A-M!")
else
say ("Error: there is something wrong with the time applescript.")
end if
delay (600)
(* Quit preview *)
say "The Weather map and preview will now quit"
tell application "Preview" to quit
delay (600)
(* Quit Thunderbird *)
say "Thunderbird will not quit"
tell application "Thunderbird" to quit
the entire script is about 28 KB
Model: Power PC G4
Browser: Firefox 3.0.13 GTB5
Operating System: Mac OS X (10.4)