static void Main(string[] args) { try { Log.Info("starting up"); if (args.Length != 1) { Log.Error("no script file path provided"); return; } if (!File.Exists(args[0])) { Log.Error($"script file does not exist: {args[0]}"); return; } var(run, ok) = Compile(args[0]); if (ok) { EventLoop.Start(); Loop.Start(() => { run(); Log.Info($"'{args[0]}' loaded"); }); } Log.Info("shutting down"); Environment.Exit(0); } finally { EventLoop.Stop(); Loop.Stop(); Lock.DisposeAll(); KeyHook.Uninstall(); WinHook.Uninstall(); } }
// Static constructor /////////////////////// static Event() { WinHook.Install((e, i) => Loop.Invoke($"event-hook {e}", () => OnEvent(e, i))); }