-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
74 lines (69 loc) · 2.51 KB
/
Program.cs
File metadata and controls
74 lines (69 loc) · 2.51 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
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Windows.Forms;
using com.jarvisniu.utils;
using Newtonsoft.Json;
namespace eCoursesExamCheater
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
public static List<List<List<string>>> questions_answers;
public static Boolean isThreadWorking = false;
public static Boolean isAppClosing = false;
[STAThread]
static void Main()
{
KeyListener keyListener = new KeyListener();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
try
{
string answersText = File.ReadAllText("./answers.json");
questions_answers = JsonConvert.DeserializeObject<List<List<List<string>>>>(answersText);
keyListener.onRelease("Ctrl+C", onPressCopy);
keyListener.onRelease("Shift+F12", onCloseApp);
MessageBox.Show("app started\npress Shift+F12 to stop app", "Made by blaud 'iblaudi@gmail.com'");
Application.Run();
} catch (Exception e) {
MessageBox.Show(e.ToString(), "Exception");
Application.Exit();
}
}
static void onPressCopy()
{
if (!isThreadWorking)
{
isThreadWorking = true;
Thread thread = new Thread(() => {
foreach (var answer in questions_answers.Select((value, i) => new { i, value }))
{
if (answer.value[0][0].Equals(Clipboard.GetText()))
{
Clipboard.SetText(answer.value[1][0]);
}
}
isThreadWorking = false;
Thread.CurrentThread.Abort();
});
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
}
}
static void onCloseApp()
{
if (!isAppClosing)
{
isAppClosing = true;
MessageBox.Show("app stopped after this window closed", "Made by blaud 'iblaudi@gmail.com'");
Application.Exit();
}
}
}
}