-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMain.cs
89 lines (82 loc) · 2.68 KB
/
Main.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
using SuchByte.MacroDeck.Plugins;
using System.Net;
using SuchByte.MacroDeck.Variables;
using jbcarreon123.AHKPlugin.GUI;
using jbcarreon123.AHKPlugin.Actions;
using SuchByte.MacroDeck.Logging;
using SuchByte.MacroDeck.Notifications;
using System.Collections.Generic;
using System.Web;
using SuchByte.MacroDeck;
using System.Drawing;
using Newtonsoft.Json;
using System.Reflection;
using System;
using System.IO;
using System.Diagnostics;
using System.Runtime.Versioning;
using Fleck;
namespace jbcarreon123.AHKPlugin
{
public static class PluginInstance
{
public static Main Main { get; set; }
}
public class Main : MacroDeckPlugin
{
public override bool CanConfigure => true;
public static Main Instance;
public Main()
{
Instance = this;
PluginInstance.Main = this;
}
public override void Enable()
{
Stopwatch stp = new Stopwatch();
stp.Start();
Instance ??= this;
CheckVersions();
if (bool.Parse(PluginConfigHelper.GetPath("v1ch")))
{
this.Actions = new List<PluginAction>
{
new RunScriptv2Action(),
new WriteScriptv2Action(),
new RunScriptAction(),
new WriteScriptAction(),
new WindowSpyAction(),
};
}
else
{
this.Actions = new List<PluginAction>
{
new RunScriptv2Action(),
new WriteScriptv2Action(),
new WindowSpyAction(),
};
}
MacroDeckLogger.Info(this, $"Finished loading AHK Plugin ({stp.ElapsedMilliseconds}ms)");
stp.Reset();
}
public override void OpenConfigurator()
{
// Open your configuration form here
using var pluginConfig = new PluginConfig();
pluginConfig.ShowDialog();
}
public void CheckVersions()
{
// checks if AHK_L field is actually AHK_L, not AHKv2
var pth = PluginConfigHelper.GetPath("v2");
if (File.Exists(pth + "\\AutoHotkeyU64.exe"))
NotificationManager.Notify(PluginInstance.Main, "Not recommended",
"Putting AHKv1 in AHKv2\"s field is not recommended.");
pth = PluginConfigHelper.GetPath("v1");
if (File.Exists(pth + "\\AutoHotkey64.exe"))
NotificationManager.Notify(PluginInstance.Main, "Not recommended",
"Putting AHKv2 in AHKv1\"s field is not recommended.");
}
}
}