Пример #1
0
 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();
     }
 }
Пример #2
0
        // Static constructor
        ///////////////////////

        static Hotkey()
        {
            KeyHook.Install(OnDown, OnUp);
            downHandlers = new Dictionary <Mod, Dictionary <Key, DownHandler> >();
            upHandlers   = new Dictionary <Mod, Dictionary <Key, Action> >();
            heldKeys     = new HashSet <Key>();
        }