예제 #1
0
        internal List <ClientHotkey> getAllHotkeys()
        {
            uint hotkeysAddr = findChildAddressByID("currentHotkeys", hotkeysWindowAdr);
            //Console.WriteLine("currentHotkeys addres: " + Convert.ToUInt32(hotkeysAddr).ToString("X"));
            List <uint> childsAddr = findAllChildsAddress(hotkeysAddr);

            List <ClientHotkey> hotkeys = new List <ClientHotkey>();

            foreach (uint addr in childsAddr)
            {
                uint lockedChildrensAddr = ReadUInt32(addr + addresses.GetUIWidgetLockedChildrensAdrress());

                //0x0 offset
                lockedChildrensAddr = ReadUInt32(lockedChildrensAddr);
                string text = ReadString(lockedChildrensAddr + 0x224);
                if (string.IsNullOrEmpty(text) || !text.Contains(":"))
                {
                    //sometimes the string is on 0x224, if the string is big then its a pointer from the string
                    lockedChildrensAddr = ReadUInt32(lockedChildrensAddr + 0x224);
                    text = ReadString(lockedChildrensAddr);
                }

                ClientHotkey hotkey = readHotkey(text);
                if (hotkey != null)
                {
                    hotkeys.Add(hotkey);
                }
            }

            return(hotkeys);
        }
예제 #2
0
        private void InputMan_ClientHotkeyPressed(object sender, ClientHotkey e)
        {
            if (!LocalInput && currentInputClient?.ClientGuid == e.TargetClient)
            {
                return;
            }

            SwitchInputToClient(e.TargetClient);
        }
예제 #3
0
        /// <summary>
        /// Removes a hotkey bound to a client
        /// </summary>
        /// <exception cref="ArgumentException>">Client hotkey not found</exception>
        /// <param name="targetClient">Guid of the client to remove the hotkey from</param>
        public void RemoveClientHotkey(Guid targetClient)
        {
            ClientHotkey chk = GetClientHotkey(targetClient);

            if (chk == null)
            {
                throw new ArgumentException("Client hotkey not found");
            }

            hotkeys.Remove(chk);
        }
예제 #4
0
        /// <summary>
        /// Add or removes a hotkey for a client
        /// </summary>
        /// <exception cref="ArgumentException">Hotkey already in use</exception>
        /// <param name="hotkey"></param>
        public void AddUpdateClientHotkey(ClientHotkey hotkey)
        {
            if (CheckHotkeyInUse(hotkey))
            {
                throw new ArgumentException("Hotkey already in use");
            }

            if (GetClientHotkey(hotkey.TargetClient) != null)
            {
                hotkeys.Remove(GetClientHotkey(hotkey.TargetClient));
            }

            ISLogger.Write("Added client hotkey " + hotkey);
            hotkeys.Add(hotkey);
        }
예제 #5
0
        private void IsThreadHandleKeyboard(uint wParam, KBDLLHOOKSTRUCT keyboardStruct)
        {
            int code = (int)wParam;

            switch (code)
            {
            case WM_SYSKEYDOWN:
            case WM_KEYDOWN:
            {
                if (keyboardStruct.scanCode == 0)
                {
                    ISLogger.Write("Cannot get scancode for virtual key {0}", keyboardStruct.vkCode);
                    return;
                }


                if (keyboardStruct.scanCode == (int)ScanCode.Control)
                {
                    currentModifiers |= Hotkey.Modifiers.Ctrl;
                }
                else if (keyboardStruct.scanCode == (int)ScanCode.Alt)
                {
                    currentModifiers |= Hotkey.Modifiers.Alt;
                }
                else if (keyboardStruct.scanCode == (int)ScanCode.LShift | keyboardStruct.scanCode == (int)ScanCode.RShift)
                {
                    currentModifiers |= Hotkey.Modifiers.Shift;
                }

                Hotkey[] list = hotkeyList.ToArray();

                for (int i = 0; i < list.Length; i++)
                {
                    if ((keyboardStruct.scanCode == (short)list[i].HkScan) && (currentModifiers == list[i].Mods))
                    {
                        if (list[i] is ClientHotkey)
                        {
                            ClientHotkey hk = list[i] as ClientHotkey;
                            ClientHotkeyPressed?.Invoke(this, hk);
                        }
                        else if (list[i] is FunctionHotkey)
                        {
                            FunctionHotkey hk = list[i] as FunctionHotkey;
                            FunctionHotkeyPressed?.Invoke(this, hk);
                        }
                    }
                }

                kbData = new ISInputData(ISInputCode.IS_KEYDOWN, (short)keyboardStruct.scanCode, 0);
                break;
            }

            case WM_SYSKEYUP:
            case WM_KEYUP:
            {
                if (keyboardStruct.scanCode == (int)ScanCode.Control)
                {
                    currentModifiers &= ~Hotkey.Modifiers.Ctrl;
                }
                else if (keyboardStruct.scanCode == (int)ScanCode.Alt)
                {
                    currentModifiers &= ~Hotkey.Modifiers.Alt;
                }
                else if (keyboardStruct.scanCode == (int)ScanCode.LShift | keyboardStruct.scanCode == (int)ScanCode.RShift)
                {
                    currentModifiers &= ~Hotkey.Modifiers.Shift;
                }
                kbData = new ISInputData(ISInputCode.IS_KEYUP, (short)keyboardStruct.scanCode, 0);
                break;
            }

            default:
            {
                ISLogger.Write("Unexpected windows keyboard input code " + code);
                return;
            }
            }


            if (UserInputBlocked)
            {
                InputReceived?.Invoke(this, kbData);
            }
        }
예제 #6
0
        private ConnectedClientInfo CreateClientInfo(ConnectedClient client, bool includeEdges)
        {
            if (client == null)
            {
                return(ConnectedClientInfo.None);
            }

            ClientHotkey hk = new ClientHotkey(0, 0, Guid.Empty);

            try
            {
                hk = inputMan.GetClientHotkey(client.ClientGuid);
            }
            catch (InvalidOperationException)
            {
            }

            if (client == ConnectedClient.LocalHost)
            {
                FunctionHotkey fhk = inputMan.GetFunctionHotkey(HotkeyFunction.SwitchToLocalInput);
                hk = new ClientHotkey(fhk.HkScan, fhk.Mods, Guid.Empty);
            }

            if (includeEdges)
            {
                ConnectedClientInfo lc;
                if (client.LeftClient == null)
                {
                    lc = ConnectedClientInfo.None;
                }
                else
                {
                    lc = CreateClientInfo(client.LeftClient, false);
                }

                ConnectedClientInfo rc;
                if (client.RightClient == null)
                {
                    rc = ConnectedClientInfo.None;
                }
                else
                {
                    rc = CreateClientInfo(client.RightClient, false);
                }

                ConnectedClientInfo ac;
                if (client.AboveClient == null)
                {
                    ac = ConnectedClientInfo.None;
                }
                else
                {
                    ac = CreateClientInfo(client.AboveClient, false);
                }
                ConnectedClientInfo bc;
                if (client.BelowClient == null)
                {
                    bc = ConnectedClientInfo.None;
                }
                else
                {
                    bc = CreateClientInfo(client.BelowClient, false);
                }

                return(new ConnectedClientInfo(client.ClientName, client.ClientGuid, client.ClientEndPoint.Address, hk,
                                               lc, rc, ac, bc));
            }
            else
            {
                return(new ConnectedClientInfo(client.ClientName, client.ClientGuid, client.ClientEndPoint.Address, hk,
                                               null, null, null, null));
            }
        }