|
|
#1 |
|
Triple-A Player
Join Date: Jan 2002
Posts: 92
|
launcher script
Hi,
In order to keep my kids from shoving CDs in and out of our iMac, I have created disk images of their favorite games, and housed them on a big partition of my hard drive. I have also written a simple AppleScript to automate the launch of each game (the scripts are housed in a tab-layer of DragThing). In short, the script looks to see if the .dmg is already mounted. If so, it just launches the game. If not, it mounts the .dmg, then launches the game. I saved it as a run-only application without the startup screen, and it works pretty slick. The only problem is that it opens (and leaves open) extra finder windows. In other words, each of the folders referenced in the 'select file...' statements (see below) are left open after running the script. Being a neat freak, I don't like this. When the game is exited, I want to return to the finder as I left it. My question is this: How can I make it close the windows it opens? It didn't leave these windows open when I did similar things under OS9. Rather, I was able to direct it to a file buried in nested folder, and have it open that file without opening all of the folders. Any other suggestions as to how to improve this script would be greatly appreciated, as well. Thanks! The script is as follows: tell application "Finder" activate if disk "Rescue Heroes" exists then select file "Rescue Heroes®" in folder "Rescue Heroes® folder" in folder "Fisher-Price" in folder "Games" of disk "einstein" open selection else select file "Rescue Heroes.dmg" in folder "•CD Images" in folder "Games" of disk "einstein" open selection select file "Rescue Heroes®" in folder "Rescue Heroes® folder" in folder "Fisher-Price" in folder "Games" of disk "einstein" open selection end if end tell |
|
|
|
|
|
#2 |
|
All Star
Join Date: Jan 2002
Location: Dexter, MI, USA
Posts: 704
|
I seem to recall that you can use an HFS-style path to the name, ie
Code:
tell application "Finder" open file "mp3's:Documents:iTunes:iTunes Music:ZZ Top:Eliminator:Sharp Dressed Man.mp3" end tell EDIT: Stupid :D being a smiley. |
|
|
|
|
|
#3 |
|
Triple-A Player
Join Date: Jan 2002
Posts: 92
|
Thanks for your response. I will try it out tonight. Another question cropped up after my initial post. The script I posted above is for a game housed on my hard dirve that needs to access the CD (or disk image, in this case). In some cases, however, the game is housed on the CD (or disk image; it does not install to the HD). In these cases, I am having problems getting the game to launch. It selects and launches the .dmg just fine, but it appears to try and launch the game from the disk image before Disk Copy finishes mounting the .dmg. Therefore, it can't find the game file. The script looks something like this (I have yet to incorporate the suggested changes):
Code:
tell application "Finder"
activate
if disk "Whatever" exists then
select file "GameOfInterest" of disk "Whatever"
open selection
else
select file "Whatever.dmg" in folder "•CD Images" in folder "Games" of disk
"einstein"
open selection
select file "GameOfInterest" of disk "Whatever"
open selection
end if
end tell
jmb |
|
|
|
|
|
#4 |
|
All Star
Join Date: Jan 2002
Location: Dexter, MI, USA
Posts: 704
|
Could you throw in a delay x command? Guesstimate how much time it takes for a disk image to open, and then add a couple of seconds to that, then replace x with that number. Your script would look something like this:
Code:
tell application "Finder"
activate
if disk "Whatever" exists then
open "Whatever:GameOfInterest"
else
open "einstein:Games:•CD Images:Whatever.dmg"
delay 10
open "Whatever:GameOfInterest"
end if
end tell
|
|
|
|
|
|
#5 |
|
Triple-A Player
Join Date: Jan 2002
Posts: 92
|
Okay, I'll try that. However, I was just thinking that it should be possible to make the launch statement (open "Whatever:GameOfInterest") contingent on whether or not Disk Copy is open. Because disk copy quits as soon as the image is mounted, the script could then go ahead and launch the game. I'm new to AppleScript, so I have no idea if this is possible, but it sounds like it should be. Any suggestions?
|
|
|
|
|
|
#6 |
|
Prospect
Join Date: Jun 2002
Location: WI
Posts: 1
|
pause option
jmb,
I think you could also put in a second if command (just like the initial one where you check if disk "whatever" exists") and if it does then go ahead and do the open, else pause a second or two and check again. -Travis N |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|