-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandomSCPScript.ps1
More file actions
165 lines (100 loc) · 4.05 KB
/
Copy pathRandomSCPScript.ps1
File metadata and controls
165 lines (100 loc) · 4.05 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#Random SCP Generator
#Seth Wagner
#10/18/2019
#Run this command before running this script: Set-ExecutionPolicy -Scope Process -ExecutionPolicy Unrestricted
#Import Modules
Import-Module Microsoft.Powershell.Management
#Main function that runs the script and calls other functions based on the selected series
function main{
UserInput
if($Series -eq 'Series 1'){
$SCP = Get-Random -Minimum 2 -Maximum 999
SCPPage -SCP $SCP
exit
}
elseif($Series -eq 'Series 2'){
$SCP = Get-Random -Minimum 1000 -Maximum 1999
SCPPage -SCP $SCP
exit
}
elseif($Series -eq 'Series 3'){
$SCP = Get-Random -Minimum 2000 -Maximum 2999
SCPPage -SCP $SCP
exit
}
elseif($Series -eq 'Series 4'){
$SCP = Get-Random -Minimum 3000 -Maximum 3999
SCPPage -SCP $SCP
exit
}
elseif($Series -eq 'Series 5'){
$SCP = Get-Random -Minimum 4000 -Maximum 4999
SCPPage -SCP $SCP
exit
}
}
#Function that displays a window asking which SCP Series the user would like to generate an SCP from.
function UserInput{
#Adds the neccessary assembly for th gui window
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName System.Drawing
#Sets up the initial form screen
$form = New-Object System.Windows.Forms.Form
$form.Text = 'Random SCP Generator'
$form.Size = New-Object System.Drawing.Size(300,200)
$form.StartPosition = 'CenterScreen'
#Adds the Ok Button
$OKButton = New-Object System.Windows.Forms.Button
$OKButton.Location = New-Object System.Drawing.Point(75,120)
$OKButton.Size = New-Object System.Drawing.Size(75,23)
$OKButton.Text = 'OK'
$OKButton.DialogResult = [System.Windows.Forms.DialogResult]::OK
$form.AcceptButton = $OKButton
$form.Controls.Add($OKButton)
#Adds the Cancel Button
$CancelButton = New-Object System.Windows.Forms.Button
$CancelButton.Location = New-Object System.Drawing.Point(150,120)
$CancelButton.Size = New-Object System.Drawing.Size(75,23)
$CancelButton.Text = 'Cancel'
$CancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
$form.CancelButton = $CancelButton
$form.Controls.Add($CancelButton)
#Label for the option menu
$methodlabel = New-Object System.Windows.Forms.Label
$methodlabel.Location = New-Object System.Drawing.Point(10,20)
$methodlabel.Size = New-Object System.Drawing.Size(280,20)
$methodlabel.Text = 'SCP Series:'
$form.Controls.Add($methodlabel)
#Option menu where user selects which series to generate from
$listBox = New-Object System.Windows.Forms.ListBox
$listBox.Location = New-Object System.Drawing.Point(10,40)
$listBox.Size = New-Object System.Drawing.Size(260,20)
$listBox.Height = 80
#Option menu selections
[void] $listBox.Items.Add('Series 1')
[void] $listBox.Items.Add('Series 2')
[void] $listBox.Items.Add('Series 3')
[void] $listBox.Items.Add('Series 4')
[void] $listBox.Items.Add('Series 5')
#Options for showing the
$form.Controls.Add($listBox)
$form.Topmost = $true
#Collects which button (OK, Cancel) the user chooses.
$result = $form.ShowDialog()
#If user clicks OK, set variables to the provided inputs, else, generate an error
if ($result -eq [System.Windows.Forms.DialogResult]::OK){
if([String]$listbox.SelectedItem -ne ""){
$script:Series = $listBox.SelectedItem
}
}
else{
Write-Error 'Please select a series to generate from!'
exit
}
}
#Function that opens the webpage of the randomly generated SCP
function SCPPage{
param($SCP)
[System.Diagnostics.Process]::Start("http://www.scp-wiki.net/scp-$SCP")
}
main