Create black screen

Hi Everyone,
I would like to make an applescript app that when run turns the screen black. I don’t want to make the screensaver activate I want the application to create the black screen. It can be a full screen window that displays the menubar if that is the only way to accomplish it.

The bottom line, I want to launch the app and see a whole lot of black.

I have no idea how to accomplish this, hopefully someone can help.

Thanks,

Tanner

Not an option with vanilla AppleScript – a black background would still show icons and the dock (although you could hide the dock).

Yeah, I was thinking if I could somehow get some type of black background I could edit the PLIST file to hide the menu bar and dock. I have done that before with apps and it works fine. I just don’t know how to make a window in applescript.

Should I pose the question in the xcode forum? It seems like just making a fullscreen window black would be easy I just haven’t ever made anything in xcode.

I don’t know if this counts as vanilla, as it uses Preview, but I use this for doing the same with a white background:


try -- Just in case there's an error, don't go crazy
	tell application "Preview"
		open ((path to me as string) & "white.jpg") as alias -- This file is located inside the application bundle, at the same directory as the Contents folder.
		activate
	end tell
	tell application "System Events"
		tell process "Preview"
			click menu item "Slideshow" of menu 1 of menu bar item "View" of menu bar 1 -- Fullscreen
		end tell
	end tell
on error
	display dialog "An error occurred!"
end try

This works by doing a few things. First, I created a 1920x1080 all-white image and placed it (as white.jpg) into my application “ I’ll explain that in a minute. Second, I told Preview.app (comes with Mac) to open the image. Next, I told System Events to click on the “Slideshow” button, which makes Preview.app fullscreen. Finally, I made sure that the script didn’t do anything strange if an error occurred.

You can place a file inside your application with three steps. First, save your script as an application (if it gives you a choice between application and application bundle, pick bundle). Next, navigate to it in the Finder and right- or control-click and press Show Package Contents. Finally, drag white.jpg (or black.jpg for you) into that directory. By default, it should only have one directory, called “Contents.”

Once you run the script, you can get to another application by using Command-Tab. To exit the black background, press escape or quit Preview.

Hope this works! :slight_smile:

BF

EDIT: Here’s a prepackaged application; I’ve tested it and it works.
http://www.multiupload.com/EX8XR6D5BW

You may want to look at this.

http://www.usingmac.com/2008/6/29/mac-how-to-hide-everything

The work mac Im at does NOT have the ‘hidden’ flag but its an old tiger box.

That’s pretty cool. Unfortunately in this case I want the black screen to generate from within my applescript app and not have to launch another program.

The program you made is exactly what I wan’t if only I didn’t need to launch preview to make it happen.

Thanks

Would it work for you to set the screen brightness to 0 ?

Exactly what I’m thinking. I’m pretty sure there’s a terminal app called brightness floating around somewhere.

do shell script "brightness 0"

would cause it to black out the screen. Swap 0 for 1 (I think) to reverse.