Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Applescript question

Applescript question
Thread Tools
Junior Member
Join Date: Jan 2003
Location: Dartmouth College, NH
Status: Offline
Reply With Quote
Mar 8, 2003, 10:13 PM
 
Hi.
One of my applications requires a disk image to be mounted in order to run. How would I write an applescript that automatically mounts the disk image when I start the application and ejects it when I quit?
I'm sorry if this is a very basic question, but I just got a mac and I'm just starting to try applescript.
Thanks,

kstor
     
Senior User
Join Date: Oct 2000
Location: Midwest
Status: Offline
Reply With Quote
Mar 14, 2003, 10:48 PM
 
To mount a disk image Disk Copy is used. getURL is the action within the Disk Copy app.

The applescript for just mounting the image is-

tell application "Disk Copy"
getURL alias "HD:users:username:desktop:xxx.img
end tell


If you can tell us a bit more about the app that needs the image mounted, perhaps I could help.

Craig
(Last edited by suthercd; Mar 14, 2003 at 10:54 PM. )
     
kstor  (op)
Junior Member
Join Date: Jan 2003
Location: Dartmouth College, NH
Status: Offline
Reply With Quote
Mar 15, 2003, 08:17 AM
 
Thanks a lot, that should make the mounting part work..
Basically, I'm trying to get a game to work without the cd, and the only way seems to have a disk image of the game mounted. So I want to make a script which will mount the disk, wait till the mounting is done, launch game, and possibly eject the disk once the game quits.
How would I do this?

KStor
     
Senior User
Join Date: Oct 2000
Location: Midwest
Status: Offline
Reply With Quote
Mar 15, 2003, 10:57 PM
 
kstor-

Once the image is mounted, is the app that is launched in the mounted disk, or does an app on your hard rive just need the mounted disk for verification?

If the app to be launched is on the mount disk, then it will not eject until the app quits.

Let me know.

Craig
     
kstor  (op)
Junior Member
Join Date: Jan 2003
Location: Dartmouth College, NH
Status: Offline
Reply With Quote
Mar 16, 2003, 01:12 PM
 
The app is on the hard drive and only needs the disk image for verification.

KStor
     
Senior User
Join Date: Oct 2000
Location: Midwest
Status: Offline
Reply With Quote
Mar 16, 2003, 02:38 PM
 
Ok. Step at a time. Applescript to launch an application for you to try is:

Tell application "HD:applications:xxx.app" to activate

You will need the accurate path to the applications. Are using using 9 or OS X?

Craig
     
kstor  (op)
Junior Member
Join Date: Jan 2003
Location: Dartmouth College, NH
Status: Offline
Reply With Quote
Mar 17, 2003, 11:58 AM
 
I'm using os x, but finding the path shouldn't be a problem I think. However, the app starts before the image has the time to mount. Is there any way I can make it wait till the disk is mounted to activate?
Also, is there anyway to unmount the disk automatically afterwards?
     
Senior User
Join Date: Oct 2000
Location: Midwest
Status: Offline
Reply With Quote
Mar 17, 2003, 09:20 PM
 
There is a display event in AS. So display 15 would pause the script for 15 seconds. This is not the best way to do this, but will work. Take a look at the Applescript dictionaries for different applications. From Script Editor there is a Dictionaries menu item.

For the Finder app there is an eject reference event. Eject is clear, reference is intially a little trickier. You would think:

eject "HD:users:kstor:desktop:cdName"

but the code is:
Code:
Tell app "Finder" eject alias "HD: yadda" end tell
or:

tell app "Finder" to eject alias "HD:yadda"

Alias returns a reference- which is required by the dictionary.

Craig
(Last edited by suthercd; Mar 17, 2003 at 09:51 PM. )
     
kstor  (op)
Junior Member
Join Date: Jan 2003
Location: Dartmouth College, NH
Status: Offline
Reply With Quote
Mar 20, 2003, 06:06 AM
 
Thanks!

KStor
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 08:52 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2