Can System Events tell whether an application is running fullscreen?

I’m writing a script that (I hope) can detect whether the DOSBox emulator software is running in fullscreen mode or in a window, and change some system settings accordingly.

I want the script to repeat with an interval of a second, and then do something like this (pseudocode)

tell application “System Events”
–next line is pseudocode!
set windowProp to properties of window 1 of application “DOSBox”
end tell
– parse the properties to see if the application is running in a window or full-screen
delay 1
end repeat

Is this possible? I haven’t been able to find the proper syntax.

Thanks for any help?

PS: Of course, I am asking about the fullscreen mode that games etc. have been using for years under all versions of OS X, NOT the new fullscreen mode added to Lion.

I’ve figured out a very indirect and (I think) kludge-y way to solve this problem. Under Lion (I haven’t tested under other versions) System Events returns an error if you try to get the properties of a window of a full-screen application. So this works:

set fullScreen to false
tell application "System Events"
	if (application process "DOSBox") exists then
			get focused of window 0 of application process "DOSBox"
		on error
			set fullScreen to true
		end try
	end if
end tell
return fullScreen

I chose to get the “focused” property of the window only because that seems to be faster than getting the full set of properties. In fact the fullscreen window is focused, but, when the application is running full screen, any attempt to get any property of the (nonexistent) window returns error number -1719.

I wonder if there is a less indirect way to do this?

This is super-kludge-y, but I found out that in Lion full screen windows aren’t included in windows of processes, only windows of applications:

tell application "Safari" to set c1 to count windows
tell application "System Events" to tell process "Safari"
	set c2 to count windows
end tell
c1 is c2

Fascinating! Does this mean that your script works in Lion but not in earlier versions? (I’m on a machine that only has Lion and can’t test it.)