jmb
03-27-2002, 09:55 PM
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
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