How to quit a OS 9 app in SheepSHaver from OS X side ?

Hi,

I use SheepShaver (an OS 9 emulator) on my Snow Leopard system. I was wondering if there is a way to quit my OS 9 app by script from the OS X side ? I get my script to tell SheepShaver to quit, but the OS 9 app requires an additional confirmation (a button to be pressed).

Is this possible ?

Robert Lespérance

Hello

If the button is a default one, try to issue a return.


tell application "System Events" to keystroke return

Yvan KOENIG (VALLAURIS, France) dimanche 15 janvier 2012 11:58:15

Thanks Yvan … It works. I had to activate it first to bring it frontmost.

In my first request, to button to be pressed was already selected, so pressing the return key closed the window and it was possible to quit the app. If the window to be closed requires to press the Cancel button and if it is not selected, how can we do that ?

Regards.

I apologize,

I know the way to do that in OS X but don’t know how to do the same with macOS 9 in SheepShaver.

You may try :


tell application "System Events" to keystroke (ASCII character 27) -- issue escape

If I remember well, in OS 9 many dialog accept Escape as a shortcut for Cancel.

Yvan KOENIG (VALLAURIS, France) dimanche 15 janvier 2012 19:21:48

Great … This should do the job. Regards.

Got it … It is maybe to simple but it works:

property appToQuitList : {"SheepShaver"}
property appHasQuit : false


repeat with i in appToQuitList
	QuitTheApp(i)
end repeat

--  To quit some applications
on QuitTheApp(theApp)
	tell application "System Events" to exists process theApp
	if result is true then
		try
			with timeout of 5 seconds
				tell application theApp to activate
				tell application "System Events" to keystroke (ASCII character 27)
				delay 2
				quit application theApp
				delay 2
				tell application "System Events" to keystroke return
			end timeout
			set appHasQuit to true
		end try
	else
		set appHasQuit to false
	end if
	return appHasQuit
end QuitTheApp

Thanks for your help.