Need a script to check if application is in fullscreen.

It seems like an easy enough problem to solve. I am not very experienced in writing scripts and I need one that constantly checks to see if a window is in fullscreen and if it is does nothing but if it isnt puts the window into fullscreen. The problem comes from a piece of commercial software that in certain circumstances reduces the size of the window, and since i cant change the software i thought I could write a script to fix it.

So whats the AppleScript equivalent to this pseudocode:

if(!window.fullscreen?)
set window.fullscreen = true;

I have searched thoroughly through google but its an odd thing to query so I am asking for help here. Any help would be greatly appreciated.

Thanks in advance,
Bill

Using system events you can get/set the size of a window in applications. To get them you can use this. To set them you can "set the size of window 1 to {x,y}. You won’t be able to make it go full screen with this technique though (without the top menu bar) but you can resize it to the size of the screen size minus the menu bar. You’d need objective-c code to go full screen.

tell application "System Events"
	tell process "Safari"
		set windowSize to size of window 1
		set windowPosition to position of window 1
	end tell
end tell

The only other idea is if the application has a menu item or some other accessible command to make its window go full screen. You could gui-script that command if the application isn’t directly apple-scriptable.