[Question]
  [
Your goal is simple: the program must turn the screen of your computer **totally black**. 
After the program is started, the screen must quickly turn completely black, and remain so until the program is exited (any key, or alt+F4, mouse movement, etc.), after which things should turn back to normal. So **shutting down the computer or turning the power of the monitor off is NOT allowed**.
Not a single non-black pixel should be visible during this time, not even a blinking cursor.
The user should not do any preparation (moving the mouse outside the screen, disconnecting cables, etc. or user input after the program started), just start the program.
You can safely assume the computer has only one monitor attached. We also assume a standard desktop or notebook computer, because doing it on a specific device without a normal monitor would be too simple.
If you use any external resources (a black image, a GUI file, etc.) their size in bytes is added to your code size.
It's OK if it only works on one OS family, or if it requires opengl etc., but requiring a very specific hardware configuration is frowned upon.
Your source code must be written in a programming language, not just a configuration file some other program (like a screen saver) will use.
  
[Answer]
**Assembly** (bootloader) 131 chars / 512 bytes compiled (actually smaller, but bootsector must be 512 bytes long.)
It is a simple boot loader. When computer starts, BIOS will load it from disk (floppy). Then it enters into graphics mode and just hangs. When user presses the power button, program will end and computer will enter to mode where is was before running program.
Tested with VirtualBox.
It will compile with nasm:
```
nasm -f bin file.asm -o start.img
```
Source code:
```
[BITS 16]
[ORG 0x7C00]
cli
mov AX,0x0
mov SS,AX
mov SP,0x9000
sti
mov AH,0x0
mov AL,0x13
int 0x10
times 510 - ($-$$) db 0
dw 0xAA55
```
[Answer]
## Bash, 28 or 12
Assuming default installation of Ubuntu 12.04 LTS.
```
gnome-screensaver-command -a
```
Automatically starts the screensaver, which is a black screen by default.
**Edit**: As suggested by @Glenn Randers-Pehrson, here's one with 12 bytes
```
/*/*/gn*d -a
```
Note that this may not work if you have another file on your system that satisfies this name, say `/tmp/1/gnd`. But it's code-golf, who cares?
---
Check out [my other bash answer](https://codegolf.stackexchange.com/a/26793/12205) if you don't use Gnome screensaver!
[Answer]
# QBASIC (31)
```
SCREEN 7
WHILE INKEY$=""
WEND
```
[Answer]
# Java : 165
Simple Java, just creates a fullscreen black frame. To exit you have to Alt+Tab back to the console and Ctrl-C, but that seems simple enough.
```
import java.awt.*;class B{public static void main(String[]a){Frame f=new Frame();f.setExtendedState(6);f.setUndecorated(1>0);f.setBackground(Color.BLACK);f.show();}}
// line breaks below
import java.awt.*;
class B{
    public static void main(String[]a){
        Frame f=new Frame();
        f.setExtendedState(6);
        f.setUndecorated(1>0);
        f.setBackground(Color.BLACK);
        f.show();
    }
}
```
[Answer]
Applesoft ][ BASIC (17)
```
1 HGR2:GET X:TEXT
```
[Answer]
# Bash - 57 ~~26~~
```
C=/s*/*/*/*/b*ess;(A=$(cat $C);echo 0;cat;echo $A)|tee $C
```
On a laptop this will set the screen backlight brightness to 0 via `/sys/class/backlight`, on a tablet or phone this will set the screen led brightness to 0 via `/sys/class/leds`
[Answer]
I know this is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") but I couldn't resist.
Just make sure you don't have any browser windows open (in this case, Chrome);
Execute this **PitchBlack.bat (~~31~~ 24 bytes)**:
```
chrome --kiosk file:///1
```
If placed in the same directory of your *Chrome.exe* file, this batch will execute Chrome in **kiosk mode** and it will open a file called **/1 (~~49~~ ~~41~~ 34 bytes)** in fullscreen:
```
<body bgcolor=0 style=cursor:none>
```
*Et voilà!*
**Total byte count: ~~80~~ ~~72~~ 58**  
Thanks to @ace :)
To exit the program, you must go for a classic **ALT+F4**; You don't actually have to do any preparation *after* the program starts (neither before, you just have to place `/1` and the batch file), so it's fine with the rules.
Please note that if you get your cursor towards the screen borders, it *may* become visible. The OP didn't say this was not allowed, since
> 
> After the program is started, the screen must quickly turn completely black, and remain so until the program is exited (any key, or alt+F4, **mouse movement**, etc.), after which things should turn back to normal. 
> 
> 
> 
So this should be totally ok! :P
[Answer]
# C# - ~~211~~ ~~202~~ ~~200~~ ~~196~~ 179 bytes
```
using System.Windows.Forms;class A{static void Main(){Cursor.Hide();new Form{BackColor=System.Drawing.Color.Black,WindowState=(FormWindowState)2,FormBorderStyle=0}.ShowDialog();}}
```
Hides the cursor and shows a full-screen black window. Can be closed with `Alt`+`F4`
**Un-golfed code**:
```
using System.Windows.Forms;
class A
{
    static void Main()
    {
        Cursor.Hide();
        new Form
        {
            BackColor = System.Drawing.Color.Black,
            WindowState = (FormWindowState)2, // FormWindowState.Maximized
            FormBorderStyle = 0 // FormBorderStyle.None
        }.ShowDialog();
    }
}
```
I don't need to cast to `FormBorderStyle`, because that's not necessary if the integer is `0`.
[Answer]
# C# ~~175~~ ~~171~~ 167
```
class P{static void Main(){SendMessage(65535,274,61808,2);}[System.Runtime.InteropServices.DllImport("user32")]static extern int SendMessage(int a,int b,int c,int d);}
```
A lot of the answers here don't actually make the screen *black*: on an LCD screen, the backlight remains on and bleeds through, leaving you with a darkish grey.
This little snippet actually tells Windows to turn off the screen, the same as what the inactivity timer does (Note: this doesn't violate the "no power off" rule because it really just causes the monitor to go into standby. *Most* monitors will turn back on when input is resumed. Also, that rule's intention seems to be to make sure the program can turn it back on - see below.)
Move the mouse or press a key to turn the screen back on.
Monitor power off adapted from <https://stackoverflow.com/a/713519/1030702>
[Answer]
# Amiga assembly
ASM-One - ~~228~~ 219 chars, 172 bytes compiled (168 bytes optimized)
It's been 20 years since I last coded a single line in Amiga assembly, so bear with me. :-)
The Amiga was a bit more involved than the PC in terms of setting up a blank screen, so tried to get rid of as much setup and teardown as possible. There's no disabling of interrupts or multitasking; no double WaitTOF; no view replacement; etc. I wouldn't even have written this for the quickest and dirtiest demo. Which means this:
* is bad practice
* may not be entirely safe
* may not always work
* even with those disclaimers, probably has stupid mistakes owing to 20 years of neglected assembly.
... although it's been tested on emulated A500 and A1200, with or without fast memory. Compiles to a standard executable. Mouse click exits.
```
l=$dff080
 move.l 4,a6
 lea g,a1
 jsr -408(a6)
 move.l d0,a1
 move.l 38(a1),d4
 jsr -412(a6)
 move.l #c,l
w:btst #6,$bfe001
 bne w
 move.l d4,l
 rts
g:dc.b "graphics.library",0
 SECTION d,DATA_C
c:dc 256,512,384,0,-1,-2
```
Less golfed:
```
COP1LC equ $dff080
    move.l  $4, a6          ; ExecBase
    lea     gfxname, a1
    jsr     -408(a6)        ; OpenLibrary (old, hence no need for clearing d0)
    move.l  d0, a1
    move.l  38(a1), d4      ; store copper list
    jsr     -414(a6)        ; CloseLibrary
                            ; Yeah, if I had a penny for the times I saw that left out
                            ; but I just... can't...
    move.l  #copper,COP1LC  ; write copper list
wait:
    btst    #6, $bfe001     ; Check mouse click
    bne     wait
    move.l  d4, COP1LC      ; restore copper list
    rts
gfxname:
    dc.b    "graphics.library", 0
    SECTION data, DATA_C
copper:
    dc.w $0100, $0200       ; disable bitplanes
    dc.w $0180, $0000       ; color 0 = black
    dc.w $ffff, $fffe       ; end
```
[Answer]
# Python / Pygame 199 127 125 92
```
from pygame import*;display.set_mode((9,9),-1<<31);mouse.set_visible(0)
while 1:event.pump()
```
Thanks to some tips from ace.
[Answer]
# TI-BASIC, 7 6
```
Shade(Ymin,Ymax
```
Works both in the terminal (home screen) or as a program. Pressing `ON` or most other buttons returns to the terminal/home screen.
[Answer]
# Commodore 64 (16 bytes)
```
ROL $A903
BRK
STA $D020
STA $D011
JSR $FF8A
JMP ($032C)
```
It has been more than 20 years since I used Turbo Assembler, so I can only provide source for use in VICE's monitor. Assemble this at $032C and `save`[1] through $033B. `Reset` and `LOAD"PITCHDARK",8,1`. Hit good ol' `Runstop+Restore`[2] to get back to normal.
How does it work?
Here's the true source:
```
032C 2E 03      .BY 2E 03
032E A9 00      LDA #$00
0330 8D 20 D0   STA $D020   ; set border color  
0333 8D 11 D0   STA $D011   ; set VIC blanking mode
0336 20 15 FD   JSR $FF8A   ; reset the vectors we trampled
0339 6C 2C 03   JMP ($032C) ; call the real CLALL
```
$032C is the [kernal](http://en.wikipedia.org/wiki/KERNAL) `CLALL` or "Close All Channels And Files" vector. As part of its cleanup, the BASIC `LOAD` command does a `CLR` which in turn calls `CLALL`. We replace the `CLALL` vector with a pointer to our own routine immediately after the vector. We set the border to black and cover the screen with the border, and then call `RESTOR` at $FF8A. The last vector replaced by `RESTOR` is `SAVE` at $0332-0333 which means the last 8 bytes are undisturbed. We then exit via the restored `CLALL` vector to continue `LOAD`'s execution.
Thanks for this, it was fun trip down memory lane, relearning how to do an autorun program :)
[1] use save and not bsave so that load with ,1 works correctly  
[2] Escape + PageUp in x64, probably.
[Answer]
## sh/X11 on Arch Linux, 26
```
b=/b*/*ht;$b =0;read;$b =7
```
[Answer]
# Bash, 37
Uses `unclutter` to hide the mouse pointer and a fullscreen session of `xterm` to black the screen. The cursor will reappear for a moment if you move it, but if you leave it alone the screen will be black until you press Ctrl+C.
It will take a few seconds for the mouse cursor to disappear (as long as you don't move it). If this isn't fast enough, add the `-grab` option to `unclutter` for an additional 6 chars.
```
unclutter&xterm -fu -bg black -e yes ''
```
**WARNING:** this will leave a process of `unclutter` running even after you press Ctrl+C, use `killall unclutter` to stop it.
## Explanation
`unclutter &` launches `unclutter`. The `&` is there so we can get on with the next command instead of waiting for this one to terminate.
`xterm -fullscreen` launches XTerm, whose background is black by default.
The `-e yes ''` option causes XTerm to run `yes ''`, thereby printing the empty string forever. This serves to hide the terminal cursor, and also provides the Ctrl+C functionality.
[Answer]
## Bash, 31 (or 52)
On a TTY, use the following script (assuming your default TTY background is black, which is true at least for Ubuntu 12.04 LTS):
```
setterm -foreground black
clear
```
Your TTY would still be fully functional even after using this script :)
If this isn't allowed, use the following (52 bytes):
```
x='setterm -foreground'
$x black
clear
read
$x white
```
And press `Enter` to terminate the script.
Special thanks to @nyuszika7h.
[Answer]
# Processing, 113
```
void setup(){noCursor();size(displayWidth, displayHeight);background(0);}boolean sketchFullScreen(){return true;}
```
I tried putting the code above onto draw() to save some bytes, but it didn't work. Press Alt-F4 to quit.
[Answer]
# ZX Spectrum Basic (29 bytes)
```
1 FOR x=0 TO 255
2 FOR y=0 TO 175
3 PLOT x,y
4 NEXT y
5 NEXT x
```
Iterates over the screen, plotting black pixels which are automatically cleared when the program finishes.
The ZX Spectrum's edition of basic uses single bytes as commands and no newlines, if counting displayed characters you get 61 chars.
[Answer]
## Lua + LÖVE (50)
```
love.mouse.setVisible()love.window.setFullscreen""
```
Both functions are supposed to take a boolean argument, yet this works.
[Answer]
## QBasic, 9 bytes
```
CLS:SLEEP
```
`CLS` clears the screen, `SLEEP` without any arguments holds execution until a key is pressed.
[Answer]
# SmileBASIC, 15 bytes
```
XSCREEN 4
EXEC.
```
Pressing START or SELECT will end the program.
`XSCREEN 4` sets the display mode to show a 320\*480 image spanning both screens. This should clear everything, so an `ACLS` is not required. `EXEC.` makes the code repeat by constantly running the program in slot 0.
I wasn't able to do `XSCREEN 4EXEC.` because you can't have a number directly before `E`
[Answer]
# Sinclair BASIC - 28 chars
```
BORDER 0:PAPER 0:CLS:PAUSE 0
```
The thing about Sinclair BASIC was each keyword had it's own character code (taking up one byte), so this would actually take up 13 bytes including spaces.
[Answer]
# SmileBASIC, 23 bytes
Runs forever until the program is force-killed with START or SELECT. This makes both screens *completely black*, going so far to disable 3D (thus turning off the 3D LED on o3DS.)
```
ACLS:XSCREEN 3@L GOTO@L
```
[Answer]
# Most POSIX compatible shells (at least `bash` and `zsh`), 21
Needs to be run on a tty
```
tput civis;clear;read
```
First command hides the cursor, second command clears the screen (duh) and third command reads a line of text
[Answer]
# BASH - 14 chars
`pmset sleepnow` does the job!
(typed into my Mac's Terminal)
[Answer]
# Bash: 48 characters
```
eval xrandr\ --output\ DP1\ --{off,auto}\;read\;
```
CW because not clear whether it qualifies due to the way it works:
* The produced black screen is real power saving: it cuts off information sending to display 1.
* Many computer displays when detect signal loss, will temporarily or periodically show their own notice.
(Note that DP1 is the first *connected* display. If you have a laptop, its embedded display is eDP1.)
[Answer]
# [HTML Application](https://en.wikipedia.org/wiki/HTML_Application) (.hta), 102 bytes
```
<HTA:APPLICATION CAPTION=no innerborder=0 border=dialog scroll=0 windowstate=maximize><body bgcolor=0>
```
[Answer]
# TI-80 BASIC, 5 bytes
```
ZOOM OUT
ZOOM OUT
GRIDON
```
[Answer]
# Chip-8, 0 bytes
> 
> [T]he original Chip-8 interpreter began execution from 0x01FC. The interpreter includes two permanent Chip-8 instructions at this location that are always executed at the start of every programme. The first of these, 0x00E0, clears the display RAM by setting all the bits to zero. The second, 0x004B, calls a machine language routine within the interpreter that switches the VIP’s display on.
> 
> 
> 
Source: <http://laurencescotford.co.uk/?p=75>
]