Ejemplo n.º 1
0
        private void ServerWindow_ClientActivated(object sender, EventArgs e)
        {
            this.Dispatcher.BeginInvoke((Action) delegate()
            {
                // set "ActiveClient" of MuboxConfig, primarily for CAS Modifiers feature
                NetworkClient networkClient = sender as NetworkClient;
                if (networkClient != null && !string.IsNullOrEmpty(networkClient.DisplayName))
                {
                    Mubox.Configuration.ClientSettings settings = Mubox.Configuration.MuboxConfigSection.Default.Teams.ActiveTeam.Clients.GetOrCreateNew(networkClient.DisplayName);
                    if (settings != null)
                    {
                        Mubox.Configuration.MuboxConfigSection.Default.Teams.ActiveTeam.ActiveClient = settings;
                    }
                }

                this.Hide();
            });
        }
Ejemplo n.º 2
0
        private static bool OnKeyboardInputReceived(WinAPI.WM wParam, WinAPI.WindowHook.KBDLLHOOKSTRUCT hookStruct)
        {
            // ignore injected input
            if (hookStruct.flags.HasFlag(WinAPI.WindowHook.LLKHF.INJECTED))
            {
                return(false);
            }

            // coerce specialized left/right shift-state to generalized shift-state
            if (MuboxConfigSection.Default.Profiles.ActiveProfile.EnableCASFix)
            {
                switch ((WinAPI.VK)hookStruct.vkCode)
                {
                case WinAPI.VK.LeftShift:
                case WinAPI.VK.RightShift:
                    hookStruct.vkCode = WinAPI.VK.Shift;
                    break;

                case WinAPI.VK.LeftMenu:
                case WinAPI.VK.RightMenu:
                    hookStruct.vkCode = WinAPI.VK.Menu;
                    break;

                case WinAPI.VK.LeftControl:
                case WinAPI.VK.RightControl:
                    hookStruct.vkCode = WinAPI.VK.Control;
                    break;
                }
            }

            // ignore "global desktop keys"
            Mubox.Configuration.KeySetting globalKeySetting = null;
            if (Mubox.Configuration.MuboxConfigSection.Default.Profiles.ActiveProfile.Keys.TryGetKeySetting((WinAPI.VK)hookStruct.vkCode, out globalKeySetting) && (globalKeySetting.SendToDesktop))
            {
                return(false);
            }

            // update pressed keys
            if (!UpdatePressedKeys(hookStruct) && Mubox.Configuration.MuboxConfigSection.Default.IsCaptureEnabled && !Mubox.Configuration.MuboxConfigSection.Default.DisableRepeatKeyFiltering)
            {
                return(true);
            }

            // count
            if (Performance.IsPerformanceEnabled)
            {
                KeyboardInputPerformance.Count(Convert.ToInt64(hookStruct.time));
            }

            // handle high-level
            if (KeyboardInputReceived != null)
            {
                KeyboardInput keyboardInputEventArgs = KeyboardInput.CreateFrom(wParam, hookStruct);
                {
                    Mubox.Configuration.KeySetting keySetting = globalKeySetting;
                    if (Mubox.Configuration.MuboxConfigSection.Default.Profiles.ActiveProfile != null)
                    {
                        Mubox.Configuration.ClientSettings activeClient = Mubox.Configuration.MuboxConfigSection.Default.Profiles.ActiveProfile.ActiveClient;
                        if (activeClient != null)
                        {
                            activeClient.Keys.TryGetKeySetting((WinAPI.VK)keyboardInputEventArgs.VK, out keySetting);
                        }
                        if (keySetting != null)
                        {
                            keyboardInputEventArgs.VK  = keySetting.OutputKey;
                            keyboardInputEventArgs.CAS = keySetting.OutputModifiers;
                        }
                    }
                }
                OnKeyboardInputReceivedInternal(keyboardInputEventArgs);
                return(keyboardInputEventArgs.Handled);
            }

            return(false);
        }