Example #1
0
        private int HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode != 0)
            {
                return(User32.CallNextHookEx(HookType.WH_KEYBOARD_LL, nCode, wParam, lParam));
            }

            uint eventType = ((uint)wParam % 2) + 256; // filter out SysKeyDown & SysKeyUp
            int  key       = Marshal.ReadInt32(lParam);

            var message = new KeyboardEventMessage {
                EventType = eventType,
                Key       = key
            };

            KeyboardResponseMessage?response = messageService.SendAndWait <KeyboardResponseMessage>(message, TimeSpan.FromMilliseconds(CALLBACK_TIMEOUT));

            if (response?.IsHandled == true)
            {
                return(1);
            }
            else
            {
                return(User32.CallNextHookEx(HookType.WH_MOUSE_LL, nCode, wParam, lParam));
            }
        }
Example #2
0
 private void Send(KeyboardEventMessage kem)
 {
     if (ServersStorage.ServerSocket != null)
     {
         sbyte[] message = kem.Message();
         byte[] payload = new byte[message.Length];
         for (int i = 0; i < message.Length; i++)
             payload[i] = (byte)message[i];
         tcptoBeSent.SetBuffer(payload, 0, payload.Length);
         ServersStorage.ServerSocket.SendAsync(tcptoBeSent);
     }
 }
Example #3
0
 private void Send(KeyboardEventMessage kem)
 {
     if (ServersStorage.ServerSocket != null)
     {
         sbyte[] message = kem.Message();
         byte[]  payload = new byte[message.Length];
         for (int i = 0; i < message.Length; i++)
         {
             payload[i] = (byte)message[i];
         }
         tcptoBeSent.SetBuffer(payload, 0, payload.Length);
         ServersStorage.ServerSocket.SendAsync(tcptoBeSent);
     }
 }
Example #4
0
        private void TextBox_KeyDown(object sender, KeyEventArgs e)
        {
            MessageBox.Show(e.PlatformKeyCode.ToString());
            NetworkMessage toSend;

            lastCode = e.PlatformKeyCode;
            if (!CharacterCode(e.PlatformKeyCode))
            {
                if (!KeySkippable(e.PlatformKeyCode))
                {
                    toSend = new KeyboardEventMessage(e.PlatformKeyCode);
                    mouseController.AddMessageToSend(toSend);
                    e.Handled = true;
                }
            }
        }
Example #5
0
 private void TextBox_KeyDown(object sender, KeyEventArgs e)
 {
     MessageBox.Show(e.PlatformKeyCode.ToString());
     NetworkMessage toSend;
     lastCode = e.PlatformKeyCode;
     if (!CharacterCode(e.PlatformKeyCode))
     {
         if (!KeySkippable(e.PlatformKeyCode))
         {
             toSend = new KeyboardEventMessage(e.PlatformKeyCode);
             mouseController.AddMessageToSend(toSend);
             e.Handled = true;
         }
     }
 }