Пример #1
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            if (!e.Args.Contains("--no-tray"))
            {
                _trayIcon = new TrayIcon(this);
                _trayIcon.Show();
            }

            // Version check updating disabled because this is a fork and it would obviously
            // be bad of us to update this forked version with the original...
            //uxsoft.VersionCheck();

            if (!StartupShortcut.IsRegistered)
            {
                StartupShortcut.Register();
            }

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

            Window = new MainWindow();

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

            if (!e.Args.Contains("--no-bullshit-keys"))
            {
                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 += new KeyboardListener.KeyHookEventHandler(KeyboardListener_KeyDown);

            Microsoft.Win32.SystemEvents.PowerModeChanged += new Microsoft.Win32.PowerModeChangedEventHandler(SystemEvents_PowerModeChanged);

            Window.Hide();
        }
 public void TriggerRefresh(object sender, EventArgs e)
 {
     if (AppleKeyboardHID2.Registered)
     {
         AppleKeyboardHID2.Shutdown();
     }
     AppleKeyboardHID2.Start();
 }
Пример #3
0
 void SystemEvents_PowerModeChanged(object sender, Microsoft.Win32.PowerModeChangedEventArgs e)
 {
     if (e.Mode == Microsoft.Win32.PowerModes.Resume)
     {
         Thread.Sleep(16000);
         AppleKeyboardHID2.Shutdown();
         AppleKeyboardHID2.Start();
     }
 }
Пример #4
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            TrayIcon.Show();
            uxsoft.VersionCheck();

            if (!StartupShortcut.IsRegistered)
            {
                StartupShortcut.Register();
            }

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

            Window = new MainWindow();

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

            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 += new KeyboardListener.KeyHookEventHandler(KeyboardListener_KeyDown);

            Microsoft.Win32.SystemEvents.PowerModeChanged += new Microsoft.Win32.PowerModeChangedEventHandler(SystemEvents_PowerModeChanged);
        }
        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();
            }
        }