Shut down SheepShaver after app closes

About SheepShaver, a PPC Mac emulator for Windows, MacOS X, and Linux that can run System 7.5.3 to MacOS 9.0.4.

Moderators: Cat_7, Ronald P. Regensburg, ClockWise

Post Reply
emendelson
Forum All-Star
Posts: 1706
Joined: Tue Oct 14, 2008 12:12 am

Shut down SheepShaver after app closes

Post by emendelson »

This has come up in various threads over years, and here's one solution that isn't satisfactory, because it takes more time than it should to quit after the application closes.

Create a "stay-open" script that runs at startup. Here is an outline of how it works, using WordPerfect as an example. It isn't enough to activate an application and then go to "on idle" - you have to wait until the process starts.

I've offered a prompt before shutting down, but of course you can simply skip the prompt and shut down without warning.

Replace "WordPerfect" with the application you want to use....

Code: Select all

tell application "WordPerfect" to activate
set wpActive to false
with timeout of 5 seconds
	tell application "Finder"
		repeat until wpActive is true
			if (get name of every process) contains "WordPerfect" then
				set wpActive to true
			end if
			delay 0.2
		end repeat
	end tell
end timeout
	
on idle
	tell application "Finder"
		if (get name of every process) contains "WordPerfect" then
		else
			activate
			display dialog "Quit SheepShaver?" buttons {"Yes", "No"} default button 1
			if button returned of result is "Yes" then
				shut down
				error number -128
			end if
		end if
	end tell
	return 1
end idle
As I said, this takes more time than it should to display the "Quit?" prompt, but otherwise, it seems to work. Improvements will be welcome.

PS: This also seems to work in Basilisk II with System 7.6.1.
User avatar
adespoton
Forum All-Star
Posts: 4227
Joined: Fri Nov 27, 2009 5:11 am
Location: Emaculation.com
Contact:

Re: Shut down SheepShaver after app closes

Post by adespoton »

Yes, that should work at least down to 7.6. I haven't tested my equivalent on that in 7.5 and lower in years, so I'm not sure if it'd work there without an OSAX.
Post Reply