Exemple #1
0
 private void MainWindow_OnKeyPressed1(object sender, Interceptor.KeyPressedEventArgs e)
 {
     Dispatcher.Invoke((Action) delegate
     {
         if (e.Key == Interceptor.Keys.F10 && !startButton.IsEnabled)
         {
             stopBot();
         }
     });
 }
Exemple #2
0
        public void OnKeyPressed(object sender, Interceptor.KeyPressedEventArgs e)
        {
            // Console.WriteLine(e.Key);
            // Console.WriteLine(e.State);

            lock (Helpers.locker)
            {
                e.Handled = true;

                // Make sure capslock is always disabled when it is used as a modifier.
                if (Options.Instance.key_bindings[Key.Modifier] == Interceptor.Keys.CapsLock)
                {
                    UncheckCapsLock();
                }

                // Interceptor.KeyState is a mess. Different Keys produce different KeyState when pressed and released.
                bool     is_e0_key = (e.State & Interceptor.KeyState.E0) != 0;
                KeyState key_state;
                if (e.State == Interceptor.KeyState.E0 || e.State == Interceptor.KeyState.Down)
                {
                    key_state = KeyState.Down;
                }
                else if ((e.State & Interceptor.KeyState.Up) != 0)
                {
                    key_state = KeyState.Up;
                }
                else
                {
                    e.Handled = false;
                    return;
                }

                // Hardcoded stop-word is Win+Del.
                if (e.Key == Interceptor.Keys.WindowsKey)
                {
                    if (key_state == KeyState.Down)
                    {
                        is_win_pressed = true;
                    }
                    else if (key_state == KeyState.Up)
                    {
                        is_win_pressed = false;
                    }
                }
                if (e.Key == Interceptor.Keys.Delete &&
                    key_state == KeyState.Down && is_win_pressed)
                {
                    Environment.Exit(0);
                    return;
                }

                if (key_state == KeyState.Down && read_key_callback != null)
                {
                    read_key_callback(new ReadKeyResult {
                        is_e0_key = is_e0_key, key = e.Key
                    });
                    read_key_callback = null;
                    e.Handled         = true;
                    return;
                }

                // Convert |Interceptor.Keys| to |eye_tracking_mouse.Key|
                var key_bindings = Options.Instance.key_bindings;
                Key key          = Key.Unbound;
                if (key_bindings.bindings.ContainsValue(e.Key))
                {
                    key = key_bindings.bindings.First(pair =>
                    {
                        return(pair.Value == e.Key);
                    }).Key;
                }

                if (key == Key.Modifier && key_bindings.is_modifier_e0 != is_e0_key)
                {
                    key = Key.Unbound;
                }

                e.Handled = receiver.OnKeyPressed(key, key_state, Helpers.IsModifier(e.Key), this);
            }
        }
 private void Input_OnKeyPressed(object sender, Interceptor.KeyPressedEventArgs e)
 {
     input.OnKeyPressed -= Input_OnKeyPressed;
     Dispatcher.BeginInvoke((Action)(() => { Close(); }));
 }
Exemple #4
0
 private void MainWindow_OnKeyPressed(object sender, Interceptor.KeyPressedEventArgs e)
 {
     Console.WriteLine(1);
 }