Please login or register.

Login with username, password and session length
Advanced search  

News:

Pages: [1]   Go Down

Author Topic: Looking for a way to automatically unmount CD images after a game quits  (Read 749 times)

n8blz

  • 16 MB
  • ***
  • Posts: 20
  • New Member

Good evening gentlemen

My kids and I do a lot of retrogaming on my old Macs. One of the constant annoyances of doing so on OS9 is the CD images and the way they accumulate and clutter up the desktop unless you eject them all. It’s such a simple, automate-able process: mount this image, open this application, when this application quits unmount this disk.

I have come across pre compiled Applescripts for OSX games that do this, but never the script source. The new and excellent software Gamebox also does this for you, so it’s clearly possible. I am wondering if anyone has an Applescript source or other helper application that can do this? I intend to share the results of this thread, if there are any, on the ‘Garden with clear instructions on how to set it up for a given game.

Thank you for your suggestions!
Logged

n8blz

  • 16 MB
  • ***
  • Posts: 20
  • New Member

Credit to MikeTomTom at the ‘Garden for writing most of the script.

Here is the applescript:

>property idlePeriod : 0.5
>
>tell application “Finder”
>   activate
>   open file “ISO-FILENAME” of folder “ISO-LOCATION-PATH” of disk “ISO-LOCATION-DISK”
>   delay 2
>   open file “GAME-FILENAME” of folder “GAME-LOCATION-PATH” of disk “GAME-LOCATION-DISK”
>end tell
>
>on idle
>   tell application “Finder”
>      set x to every process
>      set y to application “GAME-FILENAME”
>      if y is in x then
>         return idlePeriod
>      else
>         delay 5
>         put away disk “ISO-DISC-NAME”
>         quit me
>      end if
>   end tell
>end idle
>
>on quit
>   continue quit
>end quit

The below might be obvious to applescripters but I am describing it in great detail for posterity.

Where it says “ISO-FILENAME” you would write out the name of the disk image file as it appears in the Finder.

Where it says “ISO-LOCATION-PATH” you would write out the path to your image. For example, if your image is named “CD Image.iso” and is located in your Applications folder, then this whole line would read:

   open file “CD Image.iso” of folder “Applications” of startup disk

Where it says “ISO-LOCATION-DISK” you can put the name of the disk on which the ISO resides, or if it’s on your startup disk you can just put “of startup disk.”

Where it says “GAME-FILENAME” that is the name of the executable application file as it appears in the Finder.

Where it says “GAME-LOCATION-PATH” you would write out the path to your game. For example, if your game is named “Warcraft II” and is located in your Applications folder, then this whole line would read:

   open file “Warcraft II” of folder “Applications” of startup disk

Where it says “GAME-LOCATION-DISK” you can put the name of the disk on which the game resides, or if it’s on your startup disk you can just put “of startup disk.”

After writing out the script, you click on “check syntax” and it should ask you where is the application “GAME-FILENAME”. Use the open dialog box to browse to the location of that application.

In order for it to run, it must be saved as run-only, as an application, with the flags for “stay open” and “never show startup screen”
Logged

IIO

  • Staff Member
  • 4096 MB
  • *******
  • Posts: 4821
  • just a number

but is it a good idea to let a clock run in applescript while a game runs?
Logged
insert arbitrary signature here

n8blz

  • 16 MB
  • ***
  • Posts: 20
  • New Member

but is it a good idea to let a clock run in applescript while a game runs?

Good afternoon IIO

I have used it extensively on several games, up to games with high hardware requirements like UT99, Deus Ex, and similar. So far I have not noticed any performance hit, though I have yet to take fps measurements.

I think on OS9 with cooperative multitasking, the “on idle” command makes it sit and do nothing until the running application hands off cpu cycles to the applet? Because the applet seems to be completely passive until the application in question quits. Admittedly it takes a while for it to notice that the application has quit (and to eject the disk image), I have been typing to fine tune that but with little luck so far. But for my purposes, it keeps my kids and their friends from asking “why are there all these icons on the desktop”. Automatic cleanup!

Maybe it’s time to try learning some elementary realbasic and graduate from scripting, but as I have heard many people on the Garden ask for something with this function I thought I would
Logged
Pages: [1]   Go Up

Recent Topics