Пример #1
0
        private void InputMan_InputReceived(object sender, InputshareLib.Input.ISInputData input)
        {
            if (LocalInput)
            {
                return;
            }

            currentInputClient?.SendInput(input);
        }
Пример #2
0
 private void CSocket_InputReceived(object sender, InputshareLib.Input.ISInputData input)
 {
     //Check if SAS (alt+ctrl+del) was received
     if (input.Code == ISInputCode.IS_SENDSAS)
     {
         OnSASReceived();
         return;
     }
     if (ipcWrite.Connected)
     {
         //send input to SP
         ipcWrite.SendInput(input);
     }
 }
Пример #3
0
        private void IsThreadHandleMouse(uint wParam, MSLLHOOKSTRUCT mouseStruct)
        {
            int code = (int)wParam;

            switch (code)
            {
            case WM_MOUSEMOVE:
            {
                short relX = (short)(mouseStruct.pt.X - mPos.X);
                short relY = (short)(mouseStruct.pt.Y - mPos.Y);

                //Mouse hooks can sometimes report a mouse move that isnt enough for the mouse to move a single pixel, we ignore these messages
                //Sometimes the hook reports movements that make no sense (eg 1000X 1000Y) we also want to ingore these.
                if ((relX == 0 && relY == 0) || relX > 100 || relY > 100 || relX < -100 || relY < -100)
                {
                    ISLogger.Write($"Invalid movement: {relX}:{relY}");
                    mouseData = new ISInputData(ISInputCode.IS_UNKNOWN, 0, 0);
                    return;
                }

                mouseData = new ISInputData(ISInputCode.IS_MOUSEMOVERELATIVE, relX, relY);
                break;
            }

            case WM_LMOUSEDOWN:
            {
                mouseData = new ISInputData(ISInputCode.IS_MOUSELDOWN, 0, 0);
                break;
            }

            case WM_LMOUSEUP:
            {
                mouseData = new ISInputData(ISInputCode.IS_MOUSELUP, 0, 0);
                break;
            }

            case WM_RMOUSEDOWN:
            {
                mouseData = new ISInputData(ISInputCode.IS_MOUSERDOWN, 0, 0);
                break;
            }

            case WM_RMOUSEUP:
            {
                mouseData = new ISInputData(ISInputCode.IS_MOUSERUP, 0, 0);
                break;
            }

            case WM_MBUTTONDOWN:
            {
                mouseData = new ISInputData(ISInputCode.IS_MOUSEMDOWN, 0, 0);
                break;
            }

            case WM_MBUTTONUP:
            {
                mouseData = new ISInputData(ISInputCode.IS_MOUSEMUP, 0, 0);
                break;
            }

            case WM_MOUSEWHEEL:
            {
                //TODO - implement X axis scrolling
                mouseData = new ISInputData(ISInputCode.IS_MOUSEYSCROLL, unchecked ((short)((long)mouseStruct.mouseData >> 16)), 0);
                break;
            }

            case WM_XBUTTONDOWN:
            {
                mouseData = new ISInputData(ISInputCode.IS_MOUSEXDOWN, unchecked ((short)((long)mouseStruct.mouseData >> 16)), 0);
                break;
            }

            case WM_XBUTTONUP:
            {
                mouseData = new ISInputData(ISInputCode.IS_MOUSEXUP, unchecked ((short)((long)mouseStruct.mouseData >> 16)), 0);
                break;
            }

            default:
                ISLogger.Write("Unexpected windows mouse input code " + code.ToString("X"));
                mouseData = new ISInputData(ISInputCode.IS_UNKNOWN, 0, 0);
                return;
            }


            if (UserInputBlocked)
            {
                if (mouseData.Code != ISInputCode.IS_UNKNOWN)
                {
                    InputReceived?.Invoke(this, mouseData);
                }
                else
                {
                    ISLogger.Write($"Error: invalid mouse input data {mouseData.Code}:{mouseData.Param1}:{mouseData.Param2}");
                }
            }
        }
Пример #4
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);
            }
        }