Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > OS X > OS X 10.8 Mountain Lion

Reply
 
Thread Tools Search this Thread Display Modes
Old May 19, 2013, 12:17 PM   #1
TannerWord
macrumors newbie
 
Join Date: May 2013
I need AppleScript Help

I want to make a applescript so that when I save it as a application and open the application it will automatically search the tennessee lottery and tell me what the power ball, mega millions, and cash 3 number are. I found this script that does exactly what Im talking about but its for weather.....

--this is the city code. Search the code for your city on http://weather.yahoo.com/
set CityCode to 12773861
--temperature format
set t_format to "F"
--voiceover format
set v_format to "S"
--say present condition
set a_format to "Y"

set IURL to "http://weather.yahooapis.com/forecastrs… & CityCode

--downloading the file using curl
set file_content to (do shell script "curl " & IURL)
--looking for the line with actual condition
set theText to text ((offset of "yweather:condition" in file_content) + 1) thru -1 of file_content
set sub_1 to text ((offset of "\"" in theText) + 1) thru -1 of theText

--today conditions found
set actual_condition to text 1 thru ((offset of "\"" in sub_1) - 1) of sub_1

--looking for actual temperature temperature
set sub_1a to text ((offset of "temp=" in sub_1)) thru -1 of sub_1
set sub_1b to text ((offset of "\"" in sub_1a) + 1) thru -1 of sub_1a
set actual_temp to text 1 thru ((offset of "\"" in sub_1b) - 1) of sub_1b

if t_format is equal to "C" then
set actual_temp to (5 / 9) * (actual_temp - 32) as integer
end if

--looking for today forecast
set theText to text ((offset of "yweather:forecast" in file_content) + 1) thru -1 of file_content
set sub_2 to text ((offset of "\"" in theText) + 1) thru -1 of theText

--maximum and minimum temperatures found
set today_min_temp to word 9 of sub_2
set today_max_temp to word 12 of sub_2
if t_format is equal to "C" then
set today_min_temp to (5 / 9) * (today_min_temp - 32) as integer
set today_max_temp to (5 / 9) * (today_max_temp - 32) as integer
end if

--looking for today forecast condition (a bit tricky)
set sub_3 to text ((offset of "text" in sub_2) + 1) thru -1 of sub_2
set sub_4 to text ((offset of "\"" in sub_3) + 1) thru -1 of sub_3
set today_forecast to text 1 thru ((offset of "\"" in sub_4) - 1) of sub_4

--looking for tomorrow forecast
set sub_5 to text ((offset of "yweather:forecast" in sub_4) + 1) thru -1 of sub_4
set sub_6 to text ((offset of "\"" in sub_5) + 1) thru -1 of sub_5

--maximum and minimum temperatures found
set tomorrow_min_temp to word 9 of sub_6
set tomorrow_max_temp to word 12 of sub_6
if t_format is equal to "C" then
set tomorrow_min_temp to (5 / 9) * (tomorrow_min_temp - 32) as integer
set tomorrow_max_temp to (5 / 9) * (tomorrow_max_temp - 32) as integer
end if

--looking for tomorrow forecast condition (a bit tricky)
set sub_7 to text ((offset of "text" in sub_6) + 1) thru -1 of sub_6
set sub_8 to text ((offset of "\"" in sub_7) + 1) thru -1 of sub_7
set tomorrow_forecast to text 1 thru ((offset of "\"" in sub_8) - 1) of sub_8

--VoiceOver Section
set myTime to time string of (current date)
set myParts to words of myTime
set mySpeak to (item 1 of myParts) & " " & (item 2 of myParts) & " "
say "Good morning, it is " & mySpeak using "Alex"
if a_format is equal to "Y" then
say "Outside it is, " & actual_condition & ", and " & actual_temp & " degrees " using "Alex"
end if
if v_format is equal to "L" then
say "Today: " & today_forecast & ". Temperature: between " & today_min_temp & " and " & today_max_temp & " degrees.
Tomorrow: " & tomorrow_forecast & ". Temperature: between " & today_min_temp & " and " & today_max_temp & " degrees" using "Alex"
else
say "Today: " & today_forecast & ", between " & today_min_temp & " , and " & today_max_temp & " degrees.
Tomorrow: " & tomorrow_forecast & ", between " & tomorrow_min_temp & " ,and " & tomorrow_max_temp & " degrees" using "Alex"
say "I say again, Today: " & today_forecast & ". Temperature: between " & today_min_temp & " ,and " & today_max_temp & " degrees"
end if


run that in apple script and you will know what im talking about.
I want the same thing just for the lottery number of powerball,megamillions, and cash 3. Hope you can help.
Thanks!
TannerWord is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > OS X > OS X 10.8 Mountain Lion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Why so much Applescript? Dranix Mac Programming 25 May 2, 2014 01:05 AM
help with applescript andrewisgod Mac Programming 0 Apr 18, 2014 07:58 AM
AppleScript: How do I save multiple Excel sheets to one pdf using Applescript sbtaylor1 Mac Programming 0 Oct 28, 2013 11:38 PM
AppleScript: How do I save multiple Excel sheets to one pdf using Applescript sbtaylor1 Mac Applications and Mac App Store 0 Oct 28, 2013 11:32 PM
Help with an Applescript Theydonboi Mac Applications and Mac App Store 2 Nov 5, 2012 11:52 AM

Forum Jump

All times are GMT -5. The time now is 05:33 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC