예제 #1
0
 public static void TriggerRefresh(object sender, EventArgs e)
 {
     if (AppleKeyboardHID2.Registered)
     {
         AppleKeyboardHID2.Shutdown();
     }
     AppleKeyboardHID2.Start();
 }
예제 #2
0
 void SystemEvents_PowerModeChanged(object sender, Microsoft.Win32.PowerModeChangedEventArgs e)
 {
     if (e.Mode != Microsoft.Win32.PowerModes.Resume)
     {
         return;
     }
     Thread.Sleep(16000);
     AppleKeyboardHID2.Shutdown();
     AppleKeyboardHID2.Start();
 }
        internal static void SetModifiers(Key key, bool IsPressed, int VKey)
        {
            switch (key)
            {
            case Key.LeftAlt:
                ModifierLeftAlt = IsPressed;
                break;

            case Key.RightAlt:
                ModifierRightAlt = IsPressed;
                break;

            case Key.RightCtrl:
                ModifierRightCtrl = IsPressed;
                break;

            case Key.LeftCtrl:
                ModifierLeftCtrl = IsPressed;
                break;

            case Key.LeftShift:
                ModifierLeftShift = IsPressed;
                break;

            case Key.RightShift:
                ModifierRightShift = IsPressed;
                break;

            case Key.CapsLock:
                ModifierCapsLock = IsPressed;
                break;

            case Key.LWin:
                ModifierLeftWin = IsPressed;
                break;

            case Key.RWin:
                ModifierRightWin = IsPressed;
                break;
            }
            if (!AppleKeyboardHID2.Registered)
            {
                AppleKeyboardHID2.Start();
            }
        }
예제 #4
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            TrayIcon.Show();

            if (Process.GetProcessesByName(Application.ResourceAssembly.GetName().Name).Length > 1)
            {
                var processes = Process.GetProcessesByName(Application.ResourceAssembly.GetName().Name);
                foreach (var p in processes.Where(p => p != Process.GetCurrentProcess()))
                {
                    p.Kill();
                }
            }

            Window = new MainWindow();

            AppleKeyboardHID2.Start();
            AppleKeyboardHID2.KeyDown += AppleKeyboardHID_KeyDown;
            AppleKeyboardHID2.KeyUp   += AppleKeyboardHID_KeyUp;

            KeyboardListener.HookedKeys.Add(Key.F1);
            KeyboardListener.HookedKeys.Add(Key.F2);
            KeyboardListener.HookedKeys.Add(Key.F3);
            KeyboardListener.HookedKeys.Add(Key.F4);
            KeyboardListener.HookedKeys.Add(Key.F7);
            KeyboardListener.HookedKeys.Add(Key.F8);
            KeyboardListener.HookedKeys.Add(Key.F9);
            KeyboardListener.HookedKeys.Add(Key.F10);
            KeyboardListener.HookedKeys.Add(Key.F11);
            KeyboardListener.HookedKeys.Add(Key.F12);
            KeyboardListener.HookedKeys.Add(Key.Back);
            KeyboardListener.HookedKeys.Add(Key.Up);
            KeyboardListener.HookedKeys.Add(Key.Left);
            KeyboardListener.HookedKeys.Add(Key.Right);
            KeyboardListener.HookedKeys.Add(Key.Down);
            KeyboardListener.HookedKeys.Add(Key.Enter);
            KeyboardListener.Register();
            KeyboardListener.KeyDown += KeyboardListener_KeyDown;

            Microsoft.Win32.SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;

            BrightnessControl.BrightnessControl.Initialize();
        }