Ejemplo n.º 1
0
            public static bool IsKeyPressed(VirtualKeyStates testKey)
            {
                bool  keyPressed = false;
                short result     = GetKeyState(testKey);

                switch (result)
                {
                case 0:
                    // Not pressed and not toggled on.
                    keyPressed = false;
                    break;

                case 1:
                    // Not pressed, but toggled on
                    keyPressed = false;
                    break;

                default:
                    // Pressed (and may be toggled on)
                    keyPressed = true;
                    break;
                }

                return(keyPressed);
            }
Ejemplo n.º 2
0
        public static bool IsKeyPressed(VirtualKeyStates testKey)
        {
            bool keyPressed = false;
            short result = GetKeyState(testKey);

            switch (result)
            {
                case 0:
                    // Not pressed and not toggled on.
                    keyPressed = false;
                    break;

                case 1:
                    // Not pressed, but toggled on
                    keyPressed = true;
                    break;

                default:
                    // Pressed (and may be toggled on)
                    keyPressed = true;
                    break;
            }

            return keyPressed;
        }
Ejemplo n.º 3
0
        public static int GetKeyState(VirtualKeyStates testKey)
        {
            byte[] keys = new byte[256];

            //Get pressed keys
            if (!NativeMethods.GetKeyboardState(keys))
            {
                int err = Marshal.GetLastWin32Error();

                throw new Win32Exception(err);
            }

            Convert.ToBoolean(GetAsyncKeyState(Keys.ControlKey) & 0x8000);

            for (int i = 0; i < 256; i++)
            {
                byte key = keys[i];

                //Logical 'and' so we can drop the low-order bit for toggled keys, else that key will appear with the value 1!
                if ((key & 0x80) != 0)
                {
                    //This is just for a short demo, you may want this to return
                    //multiple keys!
                    return((int)key);
                }
            }
            return(-1);
        }
Ejemplo n.º 4
0
 public void ListenTo(VirtualKeyStates keyStates)
 {
     if (!KeyListeners.Contains(keyStates))
     {
         KeyListeners.Add(keyStates);
     }
 }
Ejemplo n.º 5
0
        public bool IsPressed(VirtualKeyStates key)
        {
            bool isPressed = KeyState.IsPressed(key);

            //
            return(isPressed);
        }
Ejemplo n.º 6
0
 public bool IsKeyDown(VirtualKeyStates key)
 {
     /*
      * if (null != CurrentKeys)
      *   return CurrentKeys.Contains(key);
      * return false;
      */
     if (null != CurrentKeys)
     {
         return(CurrentKeys.Contains(key));
     }
     return(false);
 }
Ejemplo n.º 7
0
 public bool IsNewKeyDown(VirtualKeyStates key)
 {
     /*
      * if (null != CurrentKeys)
      *   return CurrentKeys.Contains(key);
      * return false;
      */
     if (null != ProcessedKeys)
     {
         return(ProcessedKeys.NewKeysDown.Contains(key));
     }
     return(false);
 }
Ejemplo n.º 8
0
        public static bool IsKeyPressed(VirtualKeyStates nVirtKey)
        {
            switch (GetKeyState(nVirtKey))
            {
            case 0:
                // Not pressed and not toggled on.
                return(false);

            case 1:
                // Not pressed, but toggled on
                return(false);

            default:
                // Pressed (and may be toggled on)
                return(true);
            }
        }
Ejemplo n.º 9
0
        bool IsKeyPressed(VirtualKeyStates testKey)
        {
            bool  keyPressed = false;
            short result     = GetKeyState(testKey);

            switch (result)
            {
            case 0:
                keyPressed = false;
                break;

            case 1:
                keyPressed = false;
                break;

            default:
                keyPressed = true;
                break;
            }
            return(keyPressed);
        }
Ejemplo n.º 10
0
 public static bool IsKeyToggled(VirtualKeyStates key)
 {
     return(Convert.ToBoolean(NativeMethods.GetKeyState(VirtualKeyStates.VK_LBUTTON) & KEY_TOGGLED));
 }
Ejemplo n.º 11
0
 internal static extern int GetKeyState(VirtualKeyStates keyState);
Ejemplo n.º 12
0
 public static extern ushort GetAsyncKeyState(VirtualKeyStates nVirtKey);
Ejemplo n.º 13
0
 protected bool IsPressed(VirtualKeyStates key)
 {
     return(KeyState.IsPressed(key));
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Determina si una tecla específica está presionada
        /// </summary>
        /// <param name="keyCode">código de la tecla</param>
        /// <returns>True si la tecla está siendo presionado, false de lo contrerio</returns>
        public bool IsHardwareKeyDown(VirtualKeyStates keyCode)
        {
            var result = GetAsyncKeyState((UInt16)keyCode);

            return(result < 0);
        }
Ejemplo n.º 15
0
 public static bool IsKeyDown(VirtualKeyStates nVirtKey)
 {
     return(Convert.ToBoolean(GetKeyState(nVirtKey) & KeyPressed));
 }
Ejemplo n.º 16
0
 public static bool IsKeyDown(VirtualKeyStates nVirtKey)
 {
     return Convert.ToBoolean(GetKeyState(nVirtKey) & KeyPressed);
 }
Ejemplo n.º 17
0
 internal static extern int GetKeyState(VirtualKeyStates keyState);
Ejemplo n.º 18
0
Archivo: MWin.cs Proyecto: windwp/myexp
 public static void MSendMessage(IntPtr hWnd, UInt32 msg, VirtualKeyStates key, int num)
 {
     SendMessage(hWnd, msg, (IntPtr)key, (IntPtr)num);
 }
Ejemplo n.º 19
0
Archivo: MWin.cs Proyecto: windwp/myexp
 public static void ControlSendMessage(IntPtr hWnd, VirtualKeyStates key, bool shift, bool ctrl)
 {
     hWnd = MWin.FindWindowEx(hWnd, IntPtr.Zero, "Edit", "");
     if (shift == true)
     {
         //send shift down
         SendMessage(hWnd, WM_KEYDOWN, (IntPtr)VirtualKeyStates.VK_SHIFT, (IntPtr)0);
         //send key down
         SendMessage(hWnd, WM_KEYDOWN, (IntPtr)key, (IntPtr)0);
         //sleep 50ms
         Thread.Sleep(50);
         //send key up
         SendMessage(hWnd, WM_KEYUP, (IntPtr)key, (IntPtr)0);
         //send shift up
         SendMessage(hWnd, WM_KEYUP, (IntPtr)VirtualKeyStates.VK_SHIFT, (IntPtr)0);
     }
     else if (ctrl == true)
     {
         //send shift down
         SendMessage(hWnd, WM_KEYDOWN, (IntPtr)VirtualKeyStates.VK_CONTROL, (IntPtr)0);
         //send key down
         SendMessage(hWnd, WM_KEYDOWN, (IntPtr)key, (IntPtr)0);
         //sleep 50ms
         Thread.Sleep(50);
         //send key up
         SendMessage(hWnd, WM_KEYUP, (IntPtr)key, (IntPtr)0);
         //send shift up
         SendMessage(hWnd, WM_KEYUP, (IntPtr)VirtualKeyStates.VK_SHIFT, (IntPtr)0);
     }
     else
     {
         //send key down
         SendMessage(hWnd, WM_KEYDOWN, (IntPtr)key, (IntPtr)0);
         //sleep 50ms
         Thread.Sleep(50);
         //send key up
         SendMessage(hWnd, WM_KEYUP, (IntPtr)key, (IntPtr)0);
     }
 }
Ejemplo n.º 20
0
Archivo: MWin.cs Proyecto: windwp/myexp
 /// <summary>
 /// Sends a Keydup message(0x101) to the specified window with a Virtual Key
 /// </summary>
 /// <param name="winTitle">Window Title</param>
 /// <param name="Key">Virtual Key to Send</param>
 public static void KeyUp(string winTitle, VirtualKeyStates Key)
 {
     IntPtr hWnd = FindWindow(null, winTitle);
     SendMessage(hWnd, 0x101, (IntPtr)Key, (IntPtr)0);
 }
Ejemplo n.º 21
0
Archivo: MWin.cs Proyecto: windwp/myexp
 public static void KeyDown(string winTitle, VirtualKeyStates key)
 {
     IntPtr hWnd = FindWindow(null, winTitle);
     SendMessage(hWnd, WM_KEYDOWN, (IntPtr)key, (IntPtr)0);
 }
Ejemplo n.º 22
0
Archivo: MWin.cs Proyecto: windwp/myexp
 public static void KeyDownAndUp(IntPtr hWnd, VirtualKeyStates key)
 {
     KeyDown(hWnd, key);
     Thread.Sleep(50);
     KeyUp(hWnd, key);
 }
Ejemplo n.º 23
0
Archivo: MWin.cs Proyecto: windwp/myexp
 public static void KeyUp(IntPtr hWnd, VirtualKeyStates key)
 {
     SendMessage(hWnd, WM_KEYDOWN, (IntPtr)key, (IntPtr)0);
 }
Ejemplo n.º 24
0
 public static bool IsPressed(VirtualKeyStates key)
 {
   return Convert.ToBoolean(GetKeyState(key) & 0x8000);
 }
Ejemplo n.º 25
0
 private static extern short GetKeyState(VirtualKeyStates nVirtKey);
Ejemplo n.º 26
0
 public static bool IsKeyPressed(VirtualKeyStates nVirtKey)
 {
     return Convert.ToBoolean(GetKeyState(nVirtKey) & KEY_PRESSED);
 }
Ejemplo n.º 27
0
 private static extern short GetKeyState(VirtualKeyStates nVirtKey);
Ejemplo n.º 28
0
 public static extern short GetAsyncKeyState(VirtualKeyStates vKey);
Ejemplo n.º 29
0
 public static extern short GetAsyncKeyState(VirtualKeyStates vKey); // for applications that are not driving the message pump
Ejemplo n.º 30
0
 public static extern short GetKeyState(VirtualKeyStates nVirtKey);
Ejemplo n.º 31
0
 public static bool IsKeyPressed(VirtualKeyStates key) => GetKeyState(key) switch
 {
     0 => false, // Not pressed and not toggled on.
     1 => false, // Not pressed, but toggled on
Ejemplo n.º 32
0
 public bool IsPressed(VirtualKeyStates key)
 {
     var isPressed = KeyState.IsPressed(key);
       return isPressed;
 }
Ejemplo n.º 33
0
 internal static extern short GetKeyState(VirtualKeyStates nVirtKey);
Ejemplo n.º 34
0
        public bool IsPressed(VirtualKeyStates key)
        {
            var isPressed = KeyState.IsPressed(key);

            return(isPressed);
        }
Ejemplo n.º 35
0
 public static bool IsPressed(VirtualKeyStates key)
 {
     return(Convert.ToBoolean(GetKeyState(key) & 0x8000));
 }
Ejemplo n.º 36
0
 //KeyHook gkh = new KeyHook();
 [DllImport("USER32.dll")] static extern short GetKeyState(VirtualKeyStates nVirtKey);
Ejemplo n.º 37
0
 public static extern short GetKeyState(VirtualKeyStates nVirtKey);
Ejemplo n.º 38
0
 private bool IsPressed(VirtualKeyStates key)
 {
     return Convert.ToBoolean(GetKeyState(key) & KeyPressed);
 }
Ejemplo n.º 39
0
 public bool IsPressed(VirtualKeyStates key)
 {
     return KeyState.IsPressed(key);
 }
Ejemplo n.º 40
0
 public static extern short GetKeyState(VirtualKeyStates keyCode);
Ejemplo n.º 41
0
 public static bool IsKeyPressed(VirtualKeyStates nVirtKey)
 {
     return(Convert.ToBoolean(GetKeyState(nVirtKey) & KEY_PRESSED));
 }
Ejemplo n.º 42
0
 public static bool IsKeyPressed(VirtualKeyStates key)
 {
     return(Convert.ToBoolean(NativeMethods.GetKeyState(VirtualKeyStates.VK_LBUTTON) & KEY_PRESSED));
 }
Ejemplo n.º 43
0
 protected bool IsPressed(VirtualKeyStates key)
 {
     return KeyState.IsPressed(key);
 }
Ejemplo n.º 44
0
 [DllImport("user32")] static extern short GetKeyState(VirtualKeyStates nVirtKey);