OCInkjet.com 728x90 banner, image is updated by season.

Apple-AppleScript-Script-Editor-Logo

Shop HP Download Store and get $5 OFF Orders Over $50! Use Promo Code SPEND150SAVE15

Basic AppleScript Dialog:

display dialog "Your text here" with icon stop buttons {"OK"} default button {"OK"} giving up after 5

'giving up after 5' will automatically close the script after the indicated interval of time has elapsed.

HTML Anchor Code

Here is a sample of how to write code to link one part of your blog page to another:

<a name = "By Email">[optional text]</a> --place this where you want the link to go <a href = "#By Email">By Email</a> --this is the actual link

more HTML

HTML Code to Link to Other Web Pages

Here is a sample of code to link to another page. this is similar to the anchor code, except that the destination code is the url of the destination site:

<a href= "www.webSite.
com"> Website Name</a>

--just replace "www.webSite.
com"
with the actual url destination site and replace 'Website Name' with the prompt that the user will see.
Apple-IIc-Apple-Screen

AppleScript Note:

It might be interesting to those of you who are AppleScript enthusiasts that the HyperCard (HyperTalk) project was the prototype back in the '80's of what became the system-wide Applescript language (akin to JavaScript) that is in use today.
Apple-Mac-512-Screen
3d-iMac-Large

Trapping for List Dialog Errors

With 'List Dialog' type dialogs, since errors cannot be intercepted in an 'on error' handler, there is no 'normal' way to trap for 'Cancel' which, of course, would result in some sort of undesirable error dialog such as 'User cancelled. Error number -128'. Here is an example of one simple way I have found to trap for this type of error: set x to (choose from list {"Joe","Amy",
"Bill"} with prompt "Choose a record:")
if x is false then
else
set targetItem to (x as text)
show every record whose cell "Name" contains x
end if
When the user clicks on 'Cancel', the variable x is assigned the boolean value false. So all you have to do is set up a conditional to deal with that and to perform the usual statements otherwise.

Learning AppleScript

Create Multiple Folders with Terminal

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 mkdir Or you could create folders with the same prefix by entering: mkdir "Invoices " {"Corporate", "Individual", "Pro-Bono"}

Digg! Digg This!!

Mac LC III (1994), the first Mac that I ever owned, the CD-Rom and Zip drive were added much later.

Mac LC III (1994), the first Mac that I ever owned, the CD-Rom and Zip drive were added much later.

Basic HTML

Here is an example of a very simple HTML document:

<html>
<head>
<title>Basic HTML Document</title>
</head>
<body>
Your text goes here
</body>
</html>

more HTML

Using Say and Listen Commands with iTunes

Apple iPod Shuffle Cherry Fade
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


100x20 digg button

Apple iPod Shuffle Ad1

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

120x20 thumb black

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 statementvoiceQuery("Which playlist would you like to hear?", myMusic, 30)calls the functionon 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.

If you have questions or would like to suggest a post on another AppleScript issue, contact me at: hyperscripter@gmail.com or http://twitter.com/hyperscripter or to subscribe, click the By Email link at the top of the page

30 comments to Using 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!…

  • 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

Leave a Reply

  

  

  

HTML Guide from Peachpit Press

$1.99 Web Hosting at Go Daddy 120x240
Apple-Computer-Sticker-Old

iPhoto 6

Apple-ID-Badge
Create Multiple Folders with Terminal

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 mkdir Or you could create folders with the same prefix by entering: mkdir "Invoices " {"Corporate", "Individual", "Pro-Bono"}

AppleScript 1-2-3

Stop by every day to shop our new Deal of the Day at BarnesandNoble.com!

Add http://www.scriptsforapple.com to Technorati Favorites

Apple-iMac-Rainbow

Digg! 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