Enable fullscreen mode in Applescript Studio applications

Aug 06, '03 09:50:00AM

Contributed by: kitzkikz

I looked high and low for a way to create a full screen mode from an Applescript Studio application. I didn't find one, but I did learn enough to create one ... read the rest of the hint for the code snippets.

Add the following two files to your project:

Fullscreen.h:

#import 
#import 
@interface NSApplication (ASKAFullScreen)
- (NSWindow *)beginFullScreen;
- (void)endFullScreen;
@end
Fullscreen.mm:
#import "FullScreen.h"
NSWindow *fsWindow;
@implementation NSApplication (ASKAFullScreen)
- (NSWindow *)beginFullScreen
{   fsWindow = [
      [NSWindow alloc]
      initWithContentRect:[[NSScreen mainScreen] frame]
      styleMask:NSBorderlessWindowMask
      backing:NSBackingStoreBuffered
      defer:NO];
    NSView *fsView=[[NSView alloc] initWithFrame:[fsWindow frame]];
    [fsWindow setContentView:fsView];
    NSImageView *fsImage = [[NSImageView alloc] initWithFrame:[fsView frame]];
    [fsView addSubview:fsImage];
    [fsWindow setBackgroundColor:[NSColor blackColor]];
    [NSMenu setMenuBarVisible:0];
    [fsWindow makeKeyAndOrderFront:fsWindow];
    return fsWindow;
}
- (void)endFullScreen
{   [NSMenu setMenuBarVisible:1];
    [fsWindow close];
}
@end
Then you can use applescript to open and close the fullscreen window:
set theWindow to (call method "beginFullScreen")
call method "endFullScreen"
I hope someone else gets some use out of this example.

Comments (14)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20030804193518188