This repository has been archived by the owner on Aug 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.cs
118 lines (105 loc) · 3.38 KB
/
Form1.cs
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;
using System.Diagnostics.Eventing.Reader;
using System.Runtime.CompilerServices;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.ToolBar;
namespace gaming
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void button2_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
{
MessageBox.Show("Runner can't be trying to run nothing! Give it something to do.",
"Whoops!",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
else
{
string filePath = textBox1.Text;
if (checkBox1.Checked)
{
runasAdmin();
}
else runas();
}
}
private void runasAdmin()
{
string filePath = textBox1.Text;
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = filePath;
startInfo.Verb = "runas";
try
{
Process.Start(startInfo);
}
catch (System.ComponentModel.Win32Exception)
{
MessageBox.Show("Runner couldn't launch this resource! Have you typed it in correctly?",
"Whoops!",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
private void runas()
{
string filePath = textBox1.Text;
try
{
Process.Start(filePath);
}
catch (System.ComponentModel.Win32Exception)
{
MessageBox.Show("Runner couldn't launch this resource! Have you typed it in correctly?",
"Whoops!",
MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
private void button1_Click_1(object sender, EventArgs e)
{
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
}
private void label3_Click(object sender, EventArgs e)
{
}
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
e.SuppressKeyPress = true;
button2.PerformClick();
} else if (e.KeyCode == Keys.E && e.Alt)
{
e.Handled = true;
e.SuppressKeyPress = true;
checkBox1.Checked = !checkBox1.Checked;
}
}
}
}