Example #1
0
        public static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode >= 0)
            {
                var msg      = (WM)wParam;
                var hookInfo = Marshal.PtrToStructure <NativeMethods.KBDLLHOOKSTRUCT>(lParam);

                var key = (VirtualKey)hookInfo.vkCode;



                bool alt     = User32Methods.GetKeyState(VirtualKey.MENU).IsPressed;
                bool control = User32Methods.GetKeyState(VirtualKey.CONTROL).IsPressed;

                //if (alt && key == VirtualKey.F4)
                //{
                //    Application.Current.Shutdown();
                //    return (IntPtr)1; // Handled.
                //}

                if (!AllowKeyboardInput(alt, control, key))
                {
                    return((IntPtr)1); // Handled.
                }
            }

            return(NativeMethods.CallNextHookEx(NativeInstance._hookID, nCode, wParam, lParam));
        }
Example #2
0
        protected void OnLeftMouseButtonUp(Point point)
        {
            if (isWireForced)
            {
                if (!User32Methods.GetKeyState(VirtualKey.SHIFT).IsPressed)
                {
                    circuitBoard.UnforceWireAt(forcedWireX, forcedWireY);
                }

                isWireForced = false;
            }
        }
Example #3
0
 public void KeyReleased(VirtualKey keyCode)
 {
     KeyReleasedHandler?.Invoke(new KeyReleasedEventArgs
     {
         KeyCode   = keyCode,
         Modifiers = new KeyModifiers
         {
             Alt     = User32Methods.GetKeyState(VirtualKey.MENU).IsPressed,
             Control = User32Methods.GetKeyState(VirtualKey.CONTROL).IsPressed,
             Shift   = User32Methods.GetKeyState(VirtualKey.SHIFT).IsPressed
         }
     });
 }
Example #4
0
 public void MouseReleased(MouseButton button, int x, int y)
 {
     MouseButtonReleasedHandler?.Invoke(new MouseButtonReleasedEventArgs
     {
         Button    = button,
         Modifiers = new KeyModifiers
         {
             Alt     = User32Methods.GetKeyState(VirtualKey.MENU).IsPressed,
             Control = User32Methods.GetKeyState(VirtualKey.CONTROL).IsPressed,
             Shift   = User32Methods.GetKeyState(VirtualKey.SHIFT).IsPressed
         },
         X = x,
         Y = y
     });
 }
        public void EventLoop()
        {
            //ciclo sugli input "richiesti", assegnando i valori corretti
            for (int i = 0; i < _inputs.Keys.Count; i++)
            {
                var input = _inputs.Keys.ElementAt(i);


                if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
                {
                    var windowsVirtualKey = ConsoleToWindowsVirtualKey(input);

                    //aggiorno gli input
                    var state = User32Methods.GetKeyState(windowsVirtualKey);

                    HandleGenericKeyStatus(input, state);
                }
                else
                {
                    // do something else here
                    _xevent.NoBlockingLoop();
                }
            }
        }