In this post we look at the say and listen commands. It is a natural transition from the previous iTunes script. Before you try to run this script, go to the Speech Preferences and click on the Speech Recognition tab and click speech on. Also, if you have not used speech recognition before, click on the ‘Calibrate…’ button. It adjusts speech recognition to your personal voice to optimize its responsiveness. To refresh your memory, here is the script from the previous post, which we will use (in part) in this post. The key statements used in the script to follow are in bold text:
tell application "iTunes"
activate set visible of front window to true
set view of front window to playlist "Hall & Oates"
copy (get view of front window) to thePlaylist
set soundValue to (choose from list {"25", "50", "75", "100"} with prompt "Select volume level:" OK button name "Play" cancel button name "Abort")
set soundValue to soundValue as integer
set sound volume to soundValue play thePlaylist
end tell
The new script:
tell application "iTunes"
activate
set visible of front window to true set myMusic to (name of every playlist)
end tell
set the userResponse to voiceQuery("Which playlist would you like to hear?", myMusic, 30)
if the userResponse is false then error number -128
say "Playing " & userResponse & " please wait"
tell application "iTunes"
activate
set thePlaylist to userResponse
set view of front window to playlist thePlaylist
copy (get view of front window) to thePlaylist
play thePlaylist
end tell
on voiceQuery(userPrompt, theseItems, timeoutValue)
set the cancelCmds to {"Cancel"}
set the matchItems to cancelCmds & theseItems
try
tell application "SpeechRecognitionServer"
set the userResponse to listen for matchItems with prompt userPrompt giving up after timeoutValue displaying theseItems
end tell
if the userResponse is in the cancelCmds then
error "user cancelled"
end if
return userResponse
on error
display dialog "The music did not play!"
return false
end try
end voiceQuery
The statement ‘ set myMusic to (name of every playlist)‘ gets all of the playlists on your hard drive and puts them into the variable myMusic.
The statement ‘voiceQuery("Which playlist would you like to hear?", myMusic, 30)‘ calls the function ‘on voiceQuery(userPrompt, theseItems, timeoutValue)‘ and places the values into the corresponding variable parameters.
voiceQuery(...)returns a value in the variable userResponse and, if it is not false, plays the desired playlist.
81230 comments to http%3A%2F%2Fwww.scriptsforapple.com%2Fusing-say-and-listen-commands-with-itunes%2FUsing+Say+and+Listen+Commands+with+iTunes2009-07-02+11%3A42%3A06adminhttp%3A%2F%2Fwww.scriptsforapple.com%2F%3Fp%3D812Using Say and Listen Commands with iTunes
Best wishes on having probably the most state-of-the-art discussion boards Ive encounter in some moment in time! Its just incredible the amount you can get from one thing because of how visually attractive it really is. Youve compiled a good site space –great graphics, video footages, layout. It’s most definitely a must-see website!
Say thanks a great deal for supplying everyone shockingly marvellous chance to read critical critiques from here. It’s always so awesome plus filled with entertaining for most people personally and my office peers on the job to search one’s business at a minimum thrice inside of a weeks to read through the new stuff you could have. And then, I’m just always pleased for your putting hints yourself present. Selected 2 guidelines with this post are extremely the foremost fantastic I’ve ever had
Yo, I do think your blog might be having safari browser analysis matters. When I look at your site in Look, it seems pleasant however when opening in World wide web Traveler, it has some overlapping. We simply wished to allow a immediate minds over! Other after that that may, splendid blog!
Hey! I know this is kind of off-topic however I needed to ask. Does building a well-established website such as yours require a massive amount work? I am completely new to blogging however I do write in my journal daily. I’d like to start a blog so I will be able to share my own experience and feelings online. Please let me know if you have any kind of suggestions or tips for brand new aspiring blog owners. Thankyou!
This can be on the list of perfect posts that I’ve ever noticed; you could possibly include some even more ideas within the very same theme. I’m nevertheless waiting for some interesting thoughts from your side inside your following post.
Hmm it looks like your blog ate my first comment (it was extremely long) so I guess I’ll just sum it up what I wrote and say, I’m thoroughly enjoying your blog. I as well am an aspiring blog blogger but I’m still new to everything. Do you have any tips and hints for newbie blog writers? I’d certainly appreciate it.
Howdy! I’m at work browsing your blog from my new iphone! Just wanted to say I love reading your blog and look forward to all your posts! Carry on the fantastic work!
Hello there! This is my first visit to your blog! We are a team of volunteers and starting a new initiative in a community in the same niche. Your blog provided us valuable information to work on. You have done a marvellous job!
Hi there I am so thrilled I found your blog page. A quick question if you don’t mind. I’m really enjoying the design and layout of your site. It’s a very easy on the eyes which makes it easy to read for me to come here and visit more often. Did you hire out a designer to create your theme? Superb work!…
Do you mind if I quote a few of your articles as long as I provide credit and sources back to your webpage? My blog site is in the very same area of interest as yours and my users would certainly benefit from a lot of the information you provide here. Please let me know if this alright with you. Thanks a lot!
Hello. Absolutely dug reading your article. It was very enlightening and useful. I trust it’s ok with you if I do some blogging concerning this article on my own blog. Will definitely link back to you. Really like your theme! Your sharing is appreciated.
There is simply better way to jack up your kitchen than with a bar with some elegant looking bar stools. Never forget that the bar stools are actually what will set it all off.
ItÕs really a cool and helpful piece of info. I am glad that you shared this helpful information with us. Please keep us up to date like this. Thanks for sharing.
Excellent! Your article has a ton readers. How did you get all of these people to see your article I’m envious! I’m still learning all about article writing on the web. I’m going to click on more articles on your blog to get a better idea how to get more visable. Thanks for the assistance!
Thank you a great deal for giving everyone tremendously marvellous chance to see crucial critiques from here. It’s always therefore superior also full of enjoyable for myself in person and my workplace partners to go looking one’s business for a smallest thrice in a week to see through the new items you can have. And also, I’m just always satisfied for your putting tricks everybody present. Preferred 2 tips with this publish are very essentially the most magnificent I’ve ever endured
One unavoidably assist to create severely articles I’d state. This can be the truly to start with time period I frequented your web website page website therefore far? I astonished making use of analysis individuals fabricated to make all of this certain put up astounding. Very good method!
I just bookmarketed your website and wished to feel that We have really enjoyed reading your website posts. In any case I’ll be subscribing to your rss now, thanks
If you are more of a techy kind of person and are comfortable with using Terminal, here is a script you can use to easily create multiple folders:
First, for a single folder, type in: mkdir "Folder 1"
--or whatever you want to name your folder, this creates a new directory, which, in effect is a new folder.
To place multiple items in the 'Documents' folder:cd/Users/
Administrator/
Documents
mkdir "Folder 1" "Folder 2"
"Folder 3"To quickly create multiple folders, create a text file with the desired folder names (as many as you want) and name it something like 'folderList.txt'. Next type this in Terminal:cat folderList.txt |xargs mkdirOr you could create folders with the same prefix by entering:mkdir "Invoices " {"Corporate", "Individual", "Pro-Bono"}
AppleScript 1-2-3
Digg This!!
An AppleScript to Verify a Date
Run this in the Script Editor:
set dateRecord to (current date)
set defaultDate to (date string of dateRecord)
try
set apptDate to text returned of (display dialog "Enter appointment date:" default answer defaultDate buttons {"Set"} default button {"Set"})
set datetext to apptDate as text
date apptDate --if an invalid date is entered, the next dialog is aborted and it triggers the error alert below.
display dialog datetext & " is a valid date." with icon note buttons {"OK"} default button {"OK"}
on error
set alertText to "An error has occurred!"
set messageText to quote & datetext & quote & " is an invalid date."
display alert alertText message messageText as warning buttons {"OK"} default button "OK" giving up after 15
return
end try
Concept Drawing for iMac prior to Production
Fun HTML
Use this to add interest to your pages, but be careful, if you overdo it, it can make your page look gaudy, if not ridiculous!
Read All About It
Here's is the code as it appears above:
<p align="center" style="padding: 5px; background-color: #FFCE9C; border: dotted 5px #FFCE9C;"><marquee width=20% behavior=scroll direction=left loop=infinite> Latest Headlines... </marquee><blink>Read All About It</blink>/p>
Copy and paste this into the Script Editor and try it out:
set defaultVolume to "3"
set volumeLevel to text returned of ¬
(display dialog ¬
"Set the system volume to (7 is the highest):"¬
default answer defaultVolume with icon note¬
buttons {"OK"} default button "OK") as integer
set volumeValues to {0, 1, 2, 3, 4, 5, 6, 7} ¬
as list
if volumeLevel is not in volumeValues then ¬
set volumeLevel to defaultVolume
tell application "Finder"
try
set volume volumeLevel
beep 2
on error errDlog
display dialog errDlog with icon stop ¬
buttons {"Abort"} default button ¬
"Abort" giving up after 15
end try
end tell
Six-figure Yaro Starak Teaches You How To Set Up And Profit From A Successful Blog. Start Making Money From Blogs By Following This Step-by-step, Weekly Coaching Program
Heres an AppleScript for backing up a selected group of HyperCard files. this was used in one of my HyperCard stacks, but could be adapted for use in OSX programs with little or no modification:
send "suiteBkp(true)" to bg btn "BackupSuite"
--Use this line to call the handler below (true displays a notification dialog when the process is complete, you must have a button named bg btn "BackupSuite"):
on suiteBkp(theBoolean)
copy line 1 of field "selectedFolder" to theHFFolderPath --You'll need a hidden field named "selectedFolder" that a script (prior to the call) will place the path to the desired folder in.
tell application "Finder"
activate
set todaysDate to (current date)
set bkpYear to (year of todaysDate)
set monthlyBkp to ("Monthly Reports_" & bkpYear) as string
if exists (folder "HyperCard Backup") then
select folder "HyperCard Backup"
delete selection
end if
if exists (folder "HyperCard Backup" of folder theHFFolderPath) then
select folder "HyperCard Backup" of folder theHFFolderPath
delete selection
end if
make new folder at folder theHFFolderPath with properties {name:"HyperCard Backup"}
select {file "Appointments" of folder theHFFolderPath, ¬ file "HyperFile" of folder theHFFolderPath, ¬ file "Outstanding Invoices" of folder theHFFolderPath, ¬ file "Year" of folder theHFFolderPath, ¬ file monthlyBkp of folder theHFFolderPath, ¬
copy selection to folder "HyperCard Backup" of folder theHFFolderPath
select folder "HyperCard Backup" of folder theHFFolderPath
select file "Appointments" of folder ¬ "HyperFile Suite Backup" of folder theHFFolderPath
set name of selection to "Appointments.bkp"
select file "HyperFile" of folder "HyperCard Backup" of ¬ folder theHFFolderPath
set name of selection to "HyperFile.bkp"
select file "Outstanding Invoices" of ¬ folder "HyperFile Suite Backup" of folder theHFFolderPath
set name of selection to "Outstanding Invoices.bkp"
select file "Year" of folder "HyperFile Suite Backup" of ¬ folder theHFFolderPath
set name of selection to "Year.bkp"
set prefMonthlyBkp to (monthlyBkp & ".bkp") as string
select file monthlyBkp of folder "HyperFile Suite Backup" of ¬ folder theHFFolderPath
set name of selection to prefMonthlyBkp
select folder "HyperFile Suite Backup" of folder "The HyperFile Folder"
move selection to desktop
end tell
if theBoolean = "true" then
tell application "HyperCard"
activate
display dialog ¬ "Your backup has been saved to desktop." buttons {"Done"} default button {"Done"} with icon 129 giving up after 10
end tell
end if
end suiteBkp
The classic Apple IIc (1981), part of a series of Apple computers that preceded the debut of the Macintosh
HyperCard Users Corner:
Here's a simple, but very useful little HyperTalk script for verifying the validity of a date entered by a user, assuming that you have a menu item "flag date..." (or whatever you choose to name it) or it could be altered slightly and placed within a mouseUp statement:
if menuItem = "Flag Date..." then
global tryDate
ask "Enter a date for your new appointment:" with the long date
if it ≠ "" and the result ≠ "Cancel" then
put it into tryDate
else
put "" into tryDate
exit doMenu
end if
if invalidDate() then
answer "The date entered is not valid!"
put "" into tryDate
exit doMenu
end if
--Here you would put the statements to execute if the entered date proves to be valid
put "" into tryDate
end if
function invalidDate
global tryDate
convert tryDate to short date
if the result = "invalid date" then
return true
else
return false
end if
end invalidDate
Mac SE (circa 1987), was a more advanced version of the Mac Plus and had an internal hard drive.
YouTube Video Search Script:
tell application "Finder"
try
set webSearch to text returned of (display dialog "Enter YouTube Video
Search" default answer "" buttons {"Search", "Cancel"} default button 1)
open location "http://www.youtube.com/results?search_query=" & webSearch
on error theError
display dialog theError
end try
end tell
Best wishes on having probably the most state-of-the-art discussion boards Ive encounter in some moment in time! Its just incredible the amount you can get from one thing because of how visually attractive it really is. Youve compiled a good site space –great graphics, video footages, layout. It’s most definitely a must-see website!
Say thanks a great deal for supplying everyone shockingly marvellous chance to read critical critiques from here. It’s always so awesome plus filled with entertaining for most people personally and my office peers on the job to search one’s business at a minimum thrice inside of a weeks to read through the new stuff you could have. And then, I’m just always pleased for your putting hints yourself present. Selected 2 guidelines with this post are extremely the foremost fantastic I’ve ever had
Yo, I do think your blog might be having safari browser analysis matters. When I look at your site in Look, it seems pleasant however when opening in World wide web Traveler, it has some overlapping. We simply wished to allow a immediate minds over! Other after that that may, splendid blog!
Hey! I know this is kind of off-topic however I needed to ask. Does building a well-established website such as yours require a massive amount work? I am completely new to blogging however I do write in my journal daily. I’d like to start a blog so I will be able to share my own experience and feelings online. Please let me know if you have any kind of suggestions or tips for brand new aspiring blog owners. Thankyou!
This can be on the list of perfect posts that I’ve ever noticed; you could possibly include some even more ideas within the very same theme. I’m nevertheless waiting for some interesting thoughts from your side inside your following post.
Hmm it looks like your blog ate my first comment (it was extremely long) so I guess I’ll just sum it up what I wrote and say, I’m thoroughly enjoying your blog. I as well am an aspiring blog blogger but I’m still new to everything. Do you have any tips and hints for newbie blog writers? I’d certainly appreciate it.
Howdy! I’m at work browsing your blog from my new iphone! Just wanted to say I love reading your blog and look forward to all your posts! Carry on the fantastic work!
Hello there! This is my first visit to your blog! We are a team of volunteers and starting a new initiative in a community in the same niche. Your blog provided us valuable information to work on. You have done a marvellous job!
Hi there I am so thrilled I found your blog page. A quick question if you don’t mind. I’m really enjoying the design and layout of your site. It’s a very easy on the eyes which makes it easy to read for me to come here and visit more often. Did you hire out a designer to create your theme? Superb work!…
Hello I am so thrilled I found your website. A quick question if you don’t mind.
Do you mind if I quote a few of your articles as long as I provide credit and sources back to your webpage? My blog site is in the very same area of interest as yours and my users would certainly benefit from a lot of the information you provide here. Please let me know if this alright with you. Thanks a lot!
Hello. Absolutely dug reading your article. It was very enlightening and useful. I trust it’s ok with you if I do some blogging concerning this article on my own blog. Will definitely link back to you. Really like your theme! Your sharing is appreciated.
Awesome! I appreciate your contribution to this matter. It has been insightful. my blog: horoscope love compatibility
There is simply better way to jack up your kitchen than with a bar with some elegant looking bar stools. Never forget that the bar stools are actually what will set it all off.
ItÕs really a cool and helpful piece of info. I am glad that you shared this helpful information with us. Please keep us up to date like this. Thanks for sharing.
Excellent! Your article has a ton readers. How did you get all of these people to see your article I’m envious! I’m still learning all about article writing on the web. I’m going to click on more articles on your blog to get a better idea how to get more visable. Thanks for the assistance!
Please, can you PM me and tell me few more thinks about this approach,
Thank you a great deal for giving everyone tremendously marvellous chance to see crucial critiques from here. It’s always therefore superior also full of enjoyable for myself in person and my workplace partners to go looking one’s business for a smallest thrice in a week to see through the new items you can have. And also, I’m just always satisfied for your putting tricks everybody present. Preferred 2 tips with this publish are very essentially the most magnificent I’ve ever endured
One unavoidably assist to create severely articles I’d state. This can be the truly to start with time period I frequented your web website page website therefore far? I astonished making use of analysis individuals fabricated to make all of this certain put up astounding. Very good method!
I just bookmarketed your website and wished to feel that We have really enjoyed reading your website posts. In any case I’ll be subscribing to your rss now, thanks