d3ro-voice/scripts/verification/typing-runtime/Launch.cs

25 lines
1.3 KiB
C#

using System;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
internal static class Launch {
[STAThread] private static void Main() {
try {
var root = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../.."));
if (Process.GetProcessesByName("D3RO Voice").Length > 0) {
MessageBox.Show("Quit the installed D3RO Voice from its tray menu first, then open this launcher again. This avoids two global input hooks during verification.", "Close installed D3RO Voice first");
return;
}
if (!File.Exists(Path.Combine(root, "apps/desktop/out/main/index.js"))) {
throw new InvalidOperationException("Build the desktop product before starting verification.");
}
var start = new ProcessStartInfo(Path.Combine(root, "node_modules/electron/dist/electron.exe"));
start.Arguments = "\"" + Path.Combine(root, "scripts/verification/typing-runtime") + "\" --remote-debugging-address=127.0.0.1 --remote-debugging-port=19229";
start.WorkingDirectory = Path.Combine(root, "apps/desktop");
start.UseShellExecute = false;
start.EnvironmentVariables.Remove("ELECTRON_RUN_AS_NODE");
Process.Start(start);
} catch (Exception error) { MessageBox.Show(error.Message, "Typing verification launch failed"); }
}
}