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

TannerWord

macrumors newbie
Original poster
May 19, 2013
7
0
So i want to make something like jarvis on my mac. So im using applescript. But im a beginner so i dont know much about applescript. Currently Im using the command script:

DO SHELL SCRIPT "OPEN -a MAINSTAGE"
SAY "YES SIR"


and that works but....I have to do that on every application and folder I have which takes forever. Also, I have to make a new script like that everytime I download or make a new folder so that I can open it with my voice. I know there is a better way to do this like where if I say to open MainStage or somethinitl Search mac for mainstage and open or if I dont have it downloaded it say that it cant find it or something......and as for making it so I can speak it and it open im just saving it as a application and then saying to "make this speakable" with the built in voice commands. Also, iTunes, I dont want to make a script for Every single song seperately so I can play any song in iTunes....I know there is a way to make it so if I say "Play back in black" it will search itunes and play the song when it finds it. Or I can say to play another song and it searches itunes until it finds it and then plays it....I want to make all that in one script a quicker cleaner way so i dont have to make like 500 scripts for my 500 songs. I hope you can help!
Thanks
 
Try this out for iTunes. Its not the best execution but it should work at least. Oh and make sure you are using Mountain Lion. Maybe someone else can find a better solution.

Code:
tell application "Finder"
	set abcdsong to text returned of (display dialog "Click fn twice to activate dictation!" default answer "" buttons {"Cancel", "Ok"} default button 2)
end tell

say "Playing" & abcdsong & "in iTunes"

tell application "iTunes"
	play (file tracks whose name is abcdsong)
end tell
 
Try this out for iTunes. Its not the best execution but it should work at least. Oh and make sure you are using Mountain Lion. Maybe someone else can find a better solution.

Code:
tell application "Finder"
	set abcdsong to text returned of (display dialog "Click fn twice to activate dictation!" default answer "" buttons {"Cancel", "Ok"} default button 2)
end tell

say "Playing" & abcdsong & "in iTunes"

tell application "iTunes"
	play (file tracks whose name is abcdsong)
end tell

Thanks that is kinda what I was talking about. I want to be able to just say "play back in black" and it play...or open itunes and say what song to play....Like on the accessibility built in for the mac, all you have to do is hold down the esc key and say a command and it will do it.....thats more what I wanted. Do you know how to to that?
Thanks for they reply!
 
Thanks that is kinda what I was talking about. I want to be able to just say "play back in black" and it play...or open itunes and say what song to play....Like on the accessibility built in for the mac, all you have to do is hold down the esc key and say a command and it will do it.....thats more what I wanted. Do you know how to to that?
Thanks for they reply!

Yeah that was what I was trying to do. I was checking out some AppleScript commands and scouring the web looking for how to do that. The problem I encountered was that I couldn't figure how out how to return what the speech recognition thing picks up. I figured out how to use it, but the only thing I found was to input each possible answer manually, instead of just returning what was said as a variable. I'll keep looking, but if I don't find anything, maybe someone else can.
 
Yeah that was what I was trying to do. I was checking out some AppleScript commands and scouring the web looking for how to do that. The problem I encountered was that I couldn't figure how out how to return what the speech recognition thing picks up. I figured out how to use it, but the only thing I found was to input each possible answer manually, instead of just returning what was said as a variable. I'll keep looking, but if I don't find anything, maybe someone else can.

well, that could be usefull (putting each answer in) on other things like if I ask it whats the weather. That way I dont have to name the actual file what I wanna say and the tell it to make that speakable. So if I wanted to make it so when I say "whats the weather" it runs this script:
--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


atleast I would be able to do that so I can just hold down esc key and say whats the weather and it run that script....and Ill keep looking for what I asked earlier about Itunes too and let you know if I find something.
 
Remake of script (NOTE:bug fix edit)

Try this out for iTunes. Its not the best execution but it should work at least. Oh and make sure you are using Mountain Lion. Maybe someone else can find a better solution.

Code:
tell application "Finder"
	set abcdsong to text returned of (display dialog "Click fn twice to activate dictation!" default answer "" buttons {"Cancel", "Ok"} default button 2)
end tell

say "Playing" & abcdsong & "in iTunes"

tell application "iTunes"
	play (file tracks whose name is abcdsong)
end tell
Well here is another one,
Code:
display dialog "Click fn twice to activate dictation!" default answer "" buttons {"Cancel", "Ok"} default button 2
set abcdsong to text returned of the result

say "Playing " & abcdsong & " in iTunes"

tell application "iTunes"
	play (file tracks whose name is abcdsong)
end tell

Thank You. :):):):):):)

Garret Stand
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.