This repository has been archived by the owner on May 31, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathScreenSaver.ps1
76 lines (55 loc) · 3.04 KB
/
ScreenSaver.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
[Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[System.WIndows.Forms.Application]::EnableVisualStyles()
[System.WIndows.Forms.Application]::SetCompatibleTextRenderingDefault($false)
function Show-ScreenSaver
{
$screen = [System.Windows.Forms.Screen]::PrimaryScreen
$screenSaver = New-Object System.Windows.Forms.Form
$screenSaver.Bounds = $screen.Bounds
$screenSaver.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::None
$screenSaver.BackColor = [System.Drawing.Color]::FromArgb(17, 114, 169)
$screenSaver.TopMost = $true
$screenSaver.add_Load({
[System.Windows.Forms.Cursor]::Hide()
$this.TopMost = $true
})
$screenSaver.add_MouseClick({
[System.Windows.Forms.Application]::Exit()
})
$screenSaver.add_KeyPress({
[System.Windows.Forms.Application]::Exit()
})
$smiley = New-Object System.Windows.Forms.Label
$general = New-Object System.Windows.Forms.Label
$specific = New-Object System.Windows.Forms.Label
$smiley.Text = ":("
$general.Text = "Your PC ran into a problem that it couldn't handle, and now it needs to restart."
$specific.Text = "You can search for the error online: HAL_INITIALIZATION_FAILED"
$general.AutoSize = $false
$specific.AutoSize = $false
$smiley.ForeColor = [System.Drawing.Color]::White
$general.ForeColor = [System.Drawing.Color]::White
$specific.ForeColor = [System.Drawing.Color]::White
$smiley.Font = New-Object System.Drawing.Font -ArgumentList "Segoe UI", 100
$general.Font = New-Object System.Drawing.Font -ArgumentList "Segoe UI", 25
$specific.Font = New-Object System.Drawing.Font -ArgumentList "Segoe UI", 15
$Bounds = $screenSaver.Bounds
$smiley.Size = New-Object System.Drawing.Size -ArgumentList ($Bounds.Right - $Bounds.Left), (($Bounds.Bottom - $Bounds.Top) / 6)
$smiley.Location = new-object System.Drawing.Point -ArgumentList (($Bounds.Right - $Bounds.Left) / 4), (($Bounds.Bottom - $Bounds.Top) / 3)
$general.Size = new-object System.Drawing.Size -ArgumentList (($Bounds.Right - $Bounds.Left) / 2), (($Bounds.Bottom - $Bounds.Top) / 8)
$general.Location = New-Object System.Drawing.Point -ArgumentList (($Bounds.Right - $Bounds.Left) / 4), ($smiley.Location.Y + ($Bounds.Bottom - $Bounds.Top) / 6)
$specific.Size = new-object System.Drawing.Size -ArgumentList (($Bounds.Right - $Bounds.Left) / 2), (($Bounds.Bottom - $Bounds.Top) / 6)
$specific.Location = new-object System.Drawing.Point -ArgumentList (($Bounds.Right - $Bounds.Left) / 4), ($general.Location.Y + ($Bounds.Bottom - $Bounds.Top) / 8)
$screenSaver.Controls.Add($smiley);
$screenSaver.Controls.Add($general);
$screenSaver.Controls.Add($specific);
$screenSaver.ShowDialog()
}
$sargs = [Environment]::GetCommandLineArgs()
if ($sargs.Length -gt 0)
{
if ($sargs[1].ToLower().Trim() -eq "/s") #Full-screen mode
{
Show-ScreenSaver
}
}