Beispiel #1
0
        public void HandleKeyPress(KeyPressedEventArgs eventArgs)
        {
            WindowBox[] windowBoxes = boxRepository.GetAll().ToArray();
            foreach (WindowBox box in windowBoxes)
            {
                if (IsActiveFocus(box))
                {
                    continue;
                }

                if (IsFocusInCache(windowBoxes))
                {
                    Console.WriteLine(
                        $"Sending {eventArgs.PressedKey}({(IntPtr)eventArgs.PressedKey}, {(KeyEvent)eventArgs.KeyEvent}) to {box.MainWindowHandle}");

                    User32.SendMessage(
                        box.MainWindowHandle,
                        (int)eventArgs.KeyEvent,
                        (IntPtr)eventArgs.PressedKey,
                        IntPtr.Zero);
                }
            }
        }
Beispiel #2
0
 private bool BoxInRepository(ProcessStoppedEventArgs eventArgs)
 {
     return(boxRepository.GetAll().Any(box => box.ProcessId == eventArgs.ProcessId));
 }