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 > macOS > Script to open app and perform one function?

Script to open app and perform one function?
Thread Tools
kelesh
Dedicated MacNNer
Join Date: Mar 2003
Location: boston, ma
Status: Offline
Reply With Quote
Jul 27, 2003, 05:15 AM
 
To play Soldier of Fortune II or Freedom Force, I have to mount images with Toast Titanium 5.2. This is annoying because I have to:

1. open /Applications/Toast\ Titanium\ 5.2.app
2. hit Apple+M which opens the "choose a file to mount" dialog
3. click on Soldier_of_Fortune_II.dmg
4. click "choose"
5. wait a few seconds
6. run game (open -a Soldier\ of\ Fortune\ II

How can I write a script to do this for me? Basically I'm wondering about steps 2,3,4.
     
Art Vandelay
Professional Poster
Join Date: Sep 2002
Location: New York, NY
Status: Offline
Reply With Quote
Jul 27, 2003, 05:24 AM
 
Or you can just simply make an alias of the game on the disk image. When you double-click the alias, the OS will automatically mount the image and run the app.
Vandelay Industries
     
Art Vandelay
Professional Poster
Join Date: Sep 2002
Location: New York, NY
Status: Offline
Reply With Quote
Jul 27, 2003, 05:25 AM
 
Originally posted by Art Vandelay:
Or you can just simply make an alias of the game on the disk image. When you double-click the alias, the OS will automatically mount the image and run the app.
This also works with Dock icons too.
Vandelay Industries
     
kelesh  (op)
Dedicated MacNNer
Join Date: Mar 2003
Location: boston, ma
Status: Offline
Reply With Quote
Jul 27, 2003, 05:57 PM
 
no i HAVE to use Toast to mount the image. Using disk copy or Terminal(at least what i tried in terminal) didn't work.

It has something to do with the mounted image appearing as a CD icon and not as a Drive icon in "Computer" when it is mounted.
     
Art Vandelay
Professional Poster
Join Date: Sep 2002
Location: New York, NY
Status: Offline
Reply With Quote
Jul 27, 2003, 06:11 PM
 
You'll need to use AppleScript then. Toast may have the necessary AppleScript commands built in. If not, download GUI Scripting from apple.com/applescript and write a script that will manipulate the GUI to automate the task
Vandelay Industries
     
zachs
Mac Elite
Join Date: May 2002
Location: New York City
Status: Offline
Reply With Quote
Jul 27, 2003, 08:45 PM
 
Nevermind, lemee get the right script.
( Last edited by zachs; Jul 27, 2003 at 08:56 PM. )
     
clarkgoble
Mac Elite
Join Date: Mar 2001
Location: Provo, UT
Status: Offline
Reply With Quote
Jul 28, 2003, 12:27 AM
 
Can't you just set Toast to be the default program for dmg files rather than Disk Copy? Then it will be used to open it rather than Disk Copy.
     
clarkgoble
Mac Elite
Join Date: Mar 2001
Location: Provo, UT
Status: Offline
Reply With Quote
Jul 28, 2003, 12:32 AM
 
Can't you just set Toast to be the default program for dmg files rather than Disk Copy? Then it will be used to open it rather than Disk Copy.
     
Art Vandelay
Professional Poster
Join Date: Sep 2002
Location: New York, NY
Status: Offline
Reply With Quote
Jul 28, 2003, 12:42 AM
 
Originally posted by clarkgoble:
Can't you just set Toast to be the default program for dmg files rather than Disk Copy? Then it will be used to open it rather than Disk Copy.
Toast doesn't automatically mount the image though. That will just set Toast up to burn from it, but not mount it.
Vandelay Industries
     
Sal
Dedicated MacNNer
Join Date: Sep 2000
Location: Cupertino, CA USA
Status: Offline
Reply With Quote
Jul 28, 2003, 02:32 AM
 
Here's the dictionary for Toast Titanium. As you can see there is a "mount image" command you can use (near the bottom).

The first part of the script will look something like this:

Code:
tell application "Toast Titanium 5.2" mount image alias "Macintosh HD:Users:yourname:Desktop:thisimag.dmg" end tell
Code:
Toast Suite: Terms used to control Roxio Toast directly Class Audio disc: An Audio Disc Properties: inherits disc -- all properties and elements of the given class are inherited by this class. title string -- Get or Set the title of an audio CD. Class CD interactive disc: A CD interactive Properties: inherits disc -- all properties and elements of the given class are inherited by this class. Class Copy disc: A copy of another disc Properties: inherits disc -- all properties and elements of the given class are inherited by this class. Class DVD disc: A DVD-ROM or DVD-Video disc Properties: inherits disc -- all properties and elements of the given class are inherited by this class. resolve aliases boolean -- when this parameter is on the original files rather than their aliases will be written name string -- the name of the disc Class Data disc: A Data disc Properties: inherits disc -- all properties and elements of the given class are inherited by this class. resolve aliases boolean -- when this parameter is on the original files rather than their aliases will be written name string -- the name of the disc file system type Mac OS Standard/Mac OS Standard Hybrid/Mac OS Extended/Mac OS Extended Hybrid Class Device Copy disc: A disc copied from a storage device. It is recommended that you first set the bus and lun, then the unit ID, then the remaining properties. Properties: inherits disc -- All properties and elements of the given class are inherited by this class. scsi bus small integer -- the bus ID of the device to copy scsi id small integer -- the SCSI ID of the device to copy scsi lun small integer -- the SCSI LUN of the device to copy (almost always 0) copy blocks integer -- the number of blocks to copy from the device (changing this will also change the �copy mbytes� property) copy mbytes integer -- the number of MBytes to copy from the device (changing this will also change the �copy blocks� property) start block integer -- the block to start copying from Class Disc image disc: A disc created from a Disc Image Properties: inherits disc -- all properties and elements of the given class are inherited by this class. Class Enhanced Music CD disc: An Enhanced Music CD Properties: inherits disc -- all properties and elements of the given class are inherited by this class. macvolume alias -- create the CD from this volume optimize boolean -- optimize on-the-fly autostart string -- the name of the AutoStart file Class Hybrid disc: A Macintosh HFS / ISO 9660 Hybrid disc Properties: inherits disc -- all properties and elements of the given class are inherited by this class. macvolume alias -- the Macintosh HFS volume to be written to disc optimize boolean -- optimize for speed, size or not at all bootable boolean -- make a bootable disc (in Apple CD-ROM drives only) autostart string -- the name of the AutoStart file resolve aliases boolean -- when this parameter is on the original files rather than their aliases will be written iso format CD/CD XA -- the ISO format used for the disc iso naming ISO 9660 Level 1/Allow DOS Names/Allow Macintosh Names/Joliet -- the naming convention used for the disc append version numbers boolean -- append ;1 to all file names to satisfy the ISO 9660 standard use Apple extensions boolean -- not really necessary as the disc is hybrid Class ISO 9660 disc: An ISO 9660 disc Properties: inherits disc -- all properties and elements of the given class are inherited by this class. iso format CD/CD XA -- the ISO format used for the disc iso naming ISO 9660 Level 1/Allow DOS Names/Allow Macintosh Names/Joliet -- the naming convention used for the disc append version numbers boolean -- append ;1 to all file names to satisfy the ISO 9660 standard use Apple extensions boolean -- strongly recommended when the disc is not hybrid name string -- the name of the disc resolve aliases boolean -- when this parameter is on the original files rather than their aliases will be written Class MP3 disc: Properties: inherits disc -- all properties and elements of the given class are inherited by this class. resolve aliases boolean -- when this parameter is on the original files rather than their aliases will be written name string -- the name of the disc file system type Mac OS Standard/Mac OS Standard Hybrid/Mac OS Extended/Mac OS Extended Hybrid Class Mac Volume disc: A Macintosh HFS Volume disc Properties: inherits disc -- all properties and elements of the given class are inherited by this class. macvolume alias -- the Macintosh HFS volume to be written to disc optimize boolean -- optimize for speed, size or not at all bootable boolean -- make a bootable disc (in Apple CD-ROM drives only) autostart string -- the name of the AutoStart file Class Multitrack XA disc: A CD-ROM XA with more than one data track. Rarely used. Properties: inherits disc -- all properties and elements of the given class are inherited by this class. Class Video disc: A Video CD Properties: inherits disc -- all properties and elements of the given class are inherited by this class. name string -- the name of the disc Class application: A Macintosh application Elements: disc by numeric index Properties: current disc reference [r/o] -- the current disc busy boolean [r/o] -- currently busy recording a disc? (obsolete, use disc�s status code instead) simulation mode boolean -- writing in simulation mode? user interaction allowed/not allowed -- Whether or not the application is allowed to bring up dialogs to request user interaction. server mode boolean -- is Toast in the server mode, i.e. only showing a progress bar and no main window? media info integer [r/o] -- Information about the current media/recorder: -2 if no recorder, -1 if no medium, 0 if current medium not writable, positive values show disc capacity in sectors Class audiotrack: Elements: string by numeric index Class disc: A generic disc Plural form: discs Properties: write speed x1/x2/x4/x6/x8/x10/x12/x2/x20/x24 -- the speed used for writing size integer [r/o] -- the size of the disc in sectors number of tracks integer [r/o] -- the total number of tracks on this disc (including audio tracks) number of audio tracks integer [r/o] -- the number of audio tracks on this disc status text string [r/o] -- Toast�s current status as shown in the progress bar. status code integer [r/o] -- Toast�s current status code: 0 for idle and no error, 1 to 100 for �percent complete�, 101 for �indeterminate�, or a negative value for error codes. description string [r/o] -- A textual description of the disc�s contents. add to: Add items to an object add to reference -- the object to add items to items a list of alias -- the items to add to the object [as a list of audio tracks] -- should the items be treated as audio tracks? [at path string] -- path name at which to add the items close tray: Close the tray of the recorder (not available with every recorder) close tray compare: Compare two volumes, folders, or files. compare original alias -- The original volume, folder, or file. copy alias -- The copy of the volume, folder, or file. [Result: boolean] -- Returns TRUE if the items being compared are identical. Returns FALSE if they are not. eject: Eject the disc in the recorder eject mount image: Mount a disc image file mount image alias -- the image file to mount write: Write the specified disc to the recorder write reference -- the disc to write [asking boolean] -- should Toast ask the user before writing starts? (Default = yes) [asynchronous completion boolean] -- should the event be handled asynchronously? (Default = no) [ejecting boolean] -- should the disc be ejected after writing? (Default = yes) [verification boolean] -- should the disc be verified after writing? (Default = yes) [as session] -- should the disc be written as a session or as disc [quitting boolean] -- should Toast quit when writing is complete? (Default = no)
     
kelesh  (op)
Dedicated MacNNer
Join Date: Mar 2003
Location: boston, ma
Status: Offline
Reply With Quote
Jul 28, 2003, 03:36 AM
 
wow that's pretty cool. how did you view the dictionary for toast? (for future reference)
     
sbjordal
Dedicated MacNNer
Join Date: Jul 2000
Location: Texas
Status: Offline
Reply With Quote
Jul 28, 2003, 10:08 AM
 
Originally posted by kelesh:
To play Soldier of Fortune II or Freedom Force, I have to mount images with Toast Titanium 5.2. This is annoying because I have to:

1. open /Applications/Toast\ Titanium\ 5.2.app
2. hit Apple+M which opens the "choose a file to mount" dialog
3. click on Soldier_of_Fortune_II.dmg
4. click "choose"
5. wait a few seconds
6. run game (open -a Soldier\ of\ Fortune\ II

How can I write a script to do this for me? Basically I'm wondering about steps 2,3,4.

You could also use Quickkeys X and record a macro to do this.
---
One XP Box, One Suse Box, One Blue & White,
One ibook, One iMac 17 FP, one 30 gig iPod and a mini
happy .mac customer, os9 free since 3/24/01
     
cpac
Professional Poster
Join Date: Jul 2001
Location: New York, NY
Status: Offline
Reply With Quote
Jul 28, 2003, 10:37 AM
 
Originally posted by kelesh:
wow that's pretty cool. how did you view the dictionary for toast? (for future reference)
For most programs, you just drop the app onto script-editor, or use the "get dictionary" command in script editor.

I assume this works with toast as well.
cpac
     
   
 
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
Top
Privacy Policy
All times are GMT -4. The time now is 10:25 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,