public MediaKeyModule(SpotifyInstance instance)
        {
            _kh = new KeyboardHook("98");
            _kh.KeyDownEvent += args =>
            {
                switch (args.Key)
                {
                case Keys.MediaPlayPause:
                    //Spotify already handles Pause...but it still might be useful in case a rogue app is blocking the keys
                    //instance.TogglePlayState().Wait();

                    break;

                case Keys.MediaNextTrack:
                case Keys.MediaPreviousTrack:
                    // The underlying API uses SendKeys to implement this so we can't exactly use that in our KeyDownEvent!
                    break;

                case Keys.MediaStop:
                    instance.Pause().Wait();
                    break;
                }
            };

            //To ease development, don't bother enable this if started with the debugger attached.  Otherwise, it seems like using keyboard
            //   shortcuts to step around code confuse things
            if (!Debugger.IsAttached)
            {
                _kh.Enable();
            }
        }
Example #2
0
        private void btnKeyboadHook_Click(object sender, EventArgs e)
        {
            KeyboardHook.Enable();
            KeyboardHook.Add(Keys.S, new KeyboardHook.KeyPressed(TestKeyboadHook));

            /*bool capsLock = KeyboardHelper.CapsLock;
             * bool numLock = KeyboardHelper.NumLock;
             * bool scrollLock = KeyboardHelper.ScrollLock;
             * KeyboardHelper.SendKeys("{TAB}"); //发送Tab键
             * KeyboardHelper.SendKeys("%{F4}"); //发送Alt + F4退出*/
        }
Example #3
0
        public Core(string clientChooserTitle, string mutexName, bool proxy, bool useWPF)
        {
            KeyboardHook.Enable();

            do
            {
                ClientChooserOptions clientChooserOptions = new ClientChooserOptions();
                clientChooserOptions.Title        = clientChooserTitle;
                clientChooserOptions.ShowOTOption = true;
                clientChooserOptions.OfflineOnly  = proxy;

                if (useWPF)
                {
                    Client = ClientChooserWPF.ShowBox(clientChooserOptions);
                }
                else
                {
                    Client = ClientChooser.ShowBox(clientChooserOptions);
                }

                if (Client != null)
                {
                    kedrahMutex = new Mutex(true, "Kedrah_" + mutexName + Client.Process.Id.ToString());

                    if (!kedrahMutex.WaitOne(0, false))
                    {
                        Client = null;
                        continue;
                    }

                    System.Diagnostics.Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.AboveNormal;
                    Client.Process.Exited += new EventHandler(ClientClosed);

                    if (proxy)
                    {
                        Client.IO.StartProxy();
                        Proxy = Client.IO.Proxy;

                        Proxy.PlayerLogin  += new EventHandler(OnLogin);
                        Proxy.PlayerLogout += new EventHandler(OnLogout);
                    }
                    else
                    {
                        loginChecker.Execute += new Tibia.Util.Timer.TimerExecution(loginChecker_Execute);
                        loginChecker.Start();
                    }

                    Modules = new HModules(this);
                    Kedrah.Extensions.Core = this;
                }
            } while (Client == null);
        }
Example #4
0
        public MainWindow(string dataPath, string configPath)
        {
            if (!Directory.Exists(dataPath))
            {
                throw new FileNotFoundException(dataPath);
            }
            if (!File.Exists(configPath))
            {
                throw new FileNotFoundException(configPath);
            }

            DataPath   = dataPath;
            ConfigPath = configPath;

            InitializeComponent();

            CurrentTickTimeBadBrush  = new SolidColorBrush(Color.FromRgb(255, 0, 80));
            CurrentTickTimeGoodBrush = new SolidColorBrush(Color.FromRgb(160, 255, 0));
            DarkForegroundBrush      = new SolidColorBrush((Color)FindResource("DarkForeground"));
            DarkBackgroundBrush      = new SolidColorBrush((Color)FindResource("DarkBackground"));
            TextAccentBrush          = new SolidColorBrush((Color)FindResource("TextAccent"));

            NotificationGmBrush          = new(Colors.Cyan);
            NotificationBrush            = new(Colors.Pink);
            NotificationWhiteBrush       = new(Colors.White);
            NotificationTransparentBrush = new(Colors.Transparent);

            CurrentTickTimeBadBrush.Freeze();
            CurrentTickTimeGoodBrush.Freeze();
            DarkForegroundBrush.Freeze();
            DarkBackgroundBrush.Freeze();
            TextAccentBrush.Freeze();

            NotificationGmBrush.Freeze();
            NotificationBrush.Freeze();
            NotificationWhiteBrush.Freeze();
            NotificationTransparentBrush.Freeze();

            LabelUpdateEvent = new(TimeSpan.FromSeconds(1));

            RenderState = true;

            KeyboardHook = new KeyboardHook();
            KeyboardHook.Enable();
        }
Example #5
0
 public Hotkeys()
 {
     InitializeComponent();
     KeyboardHook.Enable();
 }