Example #1
0
        public MainForm()
        {
            InitializeComponent();

            _brightnessManager = new BrightnessManager();

            _interceptor              = new KeyInterceptor();
            _interceptor.KeyCaptured += _interceptor_KeyCaptured;
            _interceptor.Hook(this);
        }
Example #2
0
    void OnKeyDown(Keys key, int repeatCount, ref bool handled)
    {
        if (key == Keys.Space)
        {
            if (Npp.Editor.GetCurrentFilePath().EndsWith(".test"))
            {
                Modifiers modifiers = KeyInterceptor.GetModifiers();

                if (modifiers.IsCtrl && !modifiers.IsShift && !modifiers.IsAlt)
                {
                    MessageBox.Show("Ctrl+Space is pressed from KeyInterception", "Automation Scripts");
                    handled = true; //prevent other handlers (if any) form further handling of the key press event
                }
            }
        }
    }
 public MainViewModel()
 {
     KeyInterceptor.Wait(App.ActivatorKey, HandleActivatePressed);
 }
Example #4
0
        protected override void OnStartup(StartupEventArgs e)
        {
            NativeMethods.SetErrorMode(NativeMethods.SetErrorMode(0) |
                                       ErrorModes.SEM_NOGPFAULTERRORBOX |
                                       ErrorModes.SEM_FAILCRITICALERRORS |
                                       ErrorModes.SEM_NOOPENFILEERRORBOX);

            // Ensure our process has the highest priority
            Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime;

            //Application.SetCompatibleTextRenderingDefault(false);

#if !DEBUG
            // Catch unhandled exceptions
            //AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            //Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            //TaskScheduler.UnobservedTaskException += TaskScheduler_UnobservedTaskException;
#endif
            // Add the Xibo Tracelistener

            Trace.Listeners.Add(new XiboTraceListener());

            //e.Args is the string[] of command line argruments

            try
            {
                // Check for any passed arguments
                if (e.Args.Length > 0)
                {
                    if (e.Args[0].ToString() == "o")
                    {
                        RunSettings();
                    }
                    else
                    {
                        //RunClient();
                        switch (e.Args[0].ToLower().Trim().Substring(0, 2))
                        //switch (argvalue)
                        {
                        // Preview the screen saver
                        case "/p":
                            // args[1] is the handle to the preview window
                            KeyInterceptor.SetHook();
                            MouseInterceptor.SetHook();
                            RunClient(new IntPtr(long.Parse(e.Args[1])));
                            KeyInterceptor.UnsetHook();
                            MouseInterceptor.UnsetHook();
                            break;

                        // Show the screen saver
                        case "/s":
                            KeyInterceptor.SetHook();
                            MouseInterceptor.SetHook();
                            RunClient(true);
                            KeyInterceptor.UnsetHook();
                            MouseInterceptor.UnsetHook();
                            break;

                        // Configure the screesaver's settings
                        case "/c":
                            // Show the settings form
                            RunSettings();
                            break;

                        // Show the screen saver
                        default:
                            KeyInterceptor.SetHook();
                            MouseInterceptor.SetHook();
                            RunClient(true);
                            KeyInterceptor.UnsetHook();
                            MouseInterceptor.UnsetHook();
                            break;
                        }
                    }
                }
                else
                {
                    RunClient();
                }
            }
            catch (Exception ex)
            {
                HandleUnhandledException(ex);
            }
        }