forked from SergeyShch/Gear
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInputForm.cs
55 lines (51 loc) · 1.82 KB
/
InputForm.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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace TopTeam.Gear
{
public partial class InputForm : Form
{
bool btnIsClicked = false; // To prevent double adding a task to scheduler
public InputForm()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (!btnIsClicked)
{
string[] args = Environment.GetCommandLineArgs();
string taskArgs = " ";
// args[0] => app name
// args[1] => "-input"
// starts from args[2]:
for (int i = 2; i < (args.Length - 1); i++)
{
taskArgs += args[i];
taskArgs += " ";
}
// Forms a string (with params) that using as a second argument when a task added to scheduler with custom message from textbox
string taskParams = string.Format(taskArgs + Application.ExecutablePath + string.Format("\" -alert {0}\"", richTextBox1.Text));
Process.Start("SCHTASKS.EXE", taskParams);
}
btnIsClicked = true;
Program.TurnOff();
}
private void InputForm_Load(object sender, EventArgs e)
{
ToolTip toolTip1 = new ToolTip();
toolTip1.AutoPopDelay = 7000;
toolTip1.InitialDelay = 500;
toolTip1.ReshowDelay = 500;
toolTip1.ShowAlways = true;
toolTip1.SetToolTip(this.richTextBox1, "Enter your custom message and click OK or anywhere outside the form");
}
}
}