Apple Logo Itsamac Hosting
Mac OS Journal
EditorialsColumnsFeaturesReviewsArchives/StaffSubscribe
 
Table of Contents From the Desktop Connect Feature Column Special The CoXFiles The Gaming Landscape The Surf Report Simply Web Advanced HTML The Graphic Eye
Medicine Man The Database Guru The AppleScript Foundry Shop Talk Review - Dreamweaver UltraDev Review - Terminus Review - Illustrator 9 Review - Diablo II Review - Textspresso Behind the Scenes  
   
 
Itsamac.com
Red Light Runner
Applelust.com
     
 

The AppleScript Foundry
September 2000 || Volume 01, Issue 02

Welcome back to another episode of "The AppleScript Foundry!"

Every month in the AppleScript Foundry, I'll be sharing what I know about scripting. Since the object of this column is to get people who are new to scripting up and running, I will take a hands on approach, explaining new terms along the way. However, it is not my goal to talk down to the reader - If you want harder stuff, just write me! You can reach me at kevin@macosjournal.com.

Readers Write Back!

Wow. That's all I can say. The response to last month's column has been greater than I could ever have predicted. I've had several letters from AppleScripters with questions, ideas and comments. I apologize in advance to one unknown user who wrote me - I lost your letter when I reinstalled OS 9 and accidentally wiped out my message store (as well as all my other files!). Yes, these things even happen to "gurus."

[Editor's Note: Please no harassing emails from the audience... that's the job of the editing staff ;-) ]

Let's look at some of the letters.

Opening URLs in Internet Explorer

From: Skip

Subject: Cool Scripts for IE 5 and Netscape?

More than a year ago I read a great article (possibly by you) (Afraid not, I wish it was - Kevin) on how to set up an AppleScript to open Netscape and then download multiple pages in the background. I followed the directions and presto! I use this script every day for my favorite pages! At the time Internet Explorer was horrible. Now I prefer it. I have tried and tried to make the below Netscape script work for IE 5.0 but no such luck! Could you point me in the right direction??

property URL1 : "http://www.macintouch.com/"
property URL2 : "http://www.maccentral.com/"
property URL3 : "http://www.macfixit.com/"
property URL4 : "http://www.Go2Mac.com/powerpage/"
property URL5 : "http://www.deal-mac.com/"
property URL6 : "http://www.macnn.com/"
property URL7 : "http://www.xlr8yourmac.com/" 

tell application "Netscape Communicator™"
  OpenURL URL1 toWindow (make new window)
  OpenURL URL2 toWindow (make new window)
  OpenURL URL3 toWindow (make new window)
  OpenURL URL4 toWindow (make new window)
  OpenURL URL5 toWindow (make new window)
  OpenURL URL6 toWindow (make new window)
  OpenURL URL7 toWindow (make new window)
end tell

Skip, the secret is that Internet Explorer doesn't understand the "(make new window)" addition to the "toWindow" command.

Instead, IE uses a numeric switch: 1= front window, 0= New window. So the amended script reads like this:

property URL1 : "http://www.macintouch.com/"
property URL2 : "http://www.maccentral.com/"
property URL3 : "http://www.macfixit.com/"
property URL4 : "http://www.Go2Mac.com/powerpage/"
property URL5 : "http://www.deal-mac.com/"
property URL6 : "http://www.macnn.com/"
property URL7 : "http://www.xlr8yourmac.com/" 

tell application "Internet Explorer"
  OpenURL URL1 toWindow 0
  OpenURL URL2 toWindow 0
  OpenURL URL3 toWindow 0
  OpenURL URL4 toWindow 0
  OpenURL URL5 toWindow 0
  OpenURL URL6 toWindow 0
  OpenURL URL7 toWindow 0
end tell

Other readers can substitute their own favorite URLs for the ones that Skip likes - just replace them with your own favorite web page addresses. When run, the script opens a new window with each page in its own window. This is especially handy if you have a dial-up connection to the Internet, since the other pages can be downloading while you are reading the first one!

Different Scripts?

From: Derek

Subject: Hello, I have a question.

Hi, I'm a new reader of the MacOS Monthly (I'm here at Mac OS Journal now - Kevin) and I am also a new user to applescripts. Today I read your article about Folder action scripts, and when I tried to do the script, I typed everything that you showed in your picture for the article, however, when I checked the syntax, I kept getting errors, which led to the changing from your script to this:

on opening folder this_folder
  tell application "Finder"
    activate
      try
        open file "Open Sound" of this_folder
      end try
    end tell
end opening folder

This worked and now I can play a sound as soon as I open a folder or my hard drive, but I am wondering why my script is different from yours, it my be that you might be running MacOS 9, while I am running MacOS 8.6, maybe the Script Editor is different, I don't know, do you have any thoughts as to the reason? Well, thank you for reading this email, and thank you for the wonderful column, its sure to help me learn, have a nice day.

P.S. I don't know if you've heard of the site www.resexcellence.com before, but they have a section of Applescripts that people have made at http://www.ResExcellence.com/previous_edits.shtml.

Derek, I've looked at the script as published and yours, and from what I can see, they are identical. I don't know what the difference was, but apparently you have learned enough about AppleScript that you fixed it! And that means you are a true AppleScript programmer!

Seriously, there are some differences in the various releases of AppleScript, and I am using the latest version (1.4.3), so be sure you have the same version. If yours is older, surf over to Apple and grab it!

And thanks for the info about Resexcellence - I surfed over there, and you are correct. They have a lot of helpful information about AppleScript and other Mac OS topics!

Another Country Heard From

From: Thierry

Subject: Thank you very much for your Xpress script

Thanks to www.macgeneration.com I've seen that macosdaily.com is back on the web as macosjournal.com.

I'm working at the Wall Street Journal Europe here in Brussels and my mother tongue is French. In other words, sorry for my mistakes and I hope you'll understand what I want to say.

I like AppleScript even if at the newspaper we don't use it and it's due to our managers are PC users and as soon as they heard Macintosh and automation they're a little bit surprised.

Ok, I was able to read your last article about scripting Xpress, it's the program we use for the moment to prepare the newspaper. I've been searching for a long time how with Xpress to give a name to my boxes in a page, I know there is an extension to do that but I wasn't able to find it, thanks to your example script it'll be possible.

It would be nice if I could start a script with the page numbers; I mean the edition is 32 pages long, the news pages are pages 1,2,3,4 etc. the european stocks is page 13, the Nasdaq is page 23, the New York Stock Exchange is page 21,22 etc. I mean like a menu (In English we call it "Table of Contents" - Kevin). What's the page number for the European stocks tonight etc. but I don't know if something like that is possible.

Another thing I would like to make is to pick up some stock prices on different web pages I know it's possible to take the text out of a web page but do you think it's possible to include this text in an Excel sheet? This problem is for the moment more important than the rest. I'm still trying but maybe you've an idea.

I thank you for your script once again, sorry to be so long but with my little English I just wanted to explain what I wanted to do.

Thierry, I believe that the last question, about grabbing stock information and putting it into an Excel spreadsheet is very possible. I don't use Excel or have it, so the best I can do is ask our readers if they have any experience with this. Readers, if you know of a script that will do this or have written one, please send it to me and I'll forward it on to Thierry and publish it here.

The other problem, creating a table of contents for a Quark Xpress document, is much more difficult. However, you can get more Quark-specific information at The Xpressobar. Perhaps some of the links there will lead you to the script you are looking for!

Multiple Users Work Around

I recently installed the Macintosh Manager 1.3 update, and have had problems with my Multiple User accounts ever since. In particular, the Control Strip no longer comes up in any of the user accounts unless you open the Control Strip control panel and click "Show Control Strip" every time you log on. The other problem is that all users now get the main account's Appearance settings (desktop picture, fonts, etc.).

I can't fix the first problem, but with a little help from AppleScript, I managed to sidestep the second one. Here's the script:

set images_folder to path to desktop pictures folder as text
set the image_name to "My desktop"
set the file_path to images_folder & image_name

tell application "Appearance"
  set picture file of monitor 1 to file file_path
  set picture positioning of monitor 1 to automatic
   quit
end tell

Put this script (or an alias to it) in your Startup Items folder. For a user, this is located in the path "Users:username:Startup Items" of your startup disk. Then name a picture (or an alias to one) in your Desktop Pictures folder (Users:username:Desktop Pictures) to "MyDesktop."

Test the script by double-clicking it and it should replace the main user's picture on your desktop with the one you selected. If you want to know how it works, open the dictionary of the Appearance control panel in the Script Editor and find this entry:

Class monitor: Represents a monitor attached to this computer
Plural form:
  monitors
Properties:
  picture file no picture -- whether there is no desktop picture on this monitor...
  picture file alias -- ...or the file that contains the desktop picture for this monitor
  picture positioning automatic/tiled/centered/scaled/filling -- how to display the picture

Gotta Run!

More Kevin for You!

This month, Kevin took on the latest vector graphics application update from Adobe in his review of Illustrator 9. Check it out!

Well, that's all for this month. Next time, I'll be looking at some commercial scripts and scripting tools that can help you with your own scripting. Until then, keep those e-mails coming in! I try to respond to every one of them personally, if possible, and will put those that are helpful or interesting in the column.

Here is a list of places you can go to get more info on AppleScript:

Kevin's Icon Kevin Bradley - kevin@macosjournal.com
Kevin's Page - Feedback Form

 
back Mac OS Journal forward

 
 
   
© 2000 - 2004, MacOSJournal.com. All rights reserved. No part of this publication may be reproduced in any way without prior, expressed permission from the Publisher. It is the sole property of MacOSJournal.com and its writers, who retain copyright to their own works. If you wish to link to us, please see our Privacy Statement for conditions. Apple, Macintosh, and Mac are trademarks of Apple Computer, Inc, with whom we are in no way affiliated or endorsed.
Hosting provided by itsamac.com -- Macintosh Powered Web Hosting
Serve Different