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.
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.
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.