ACAT.Lib.Core.Utility.User32Interop.keybd_event C# (CSharp) Метод

keybd_event() приватный Метод

private keybd_event ( byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo ) : void
bVk byte
bScan byte
dwFlags uint
dwExtraInfo UIntPtr
Результат void
        public static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, UIntPtr dwExtraInfo);

Usage Example

Пример #1
0
        /// <summary>
        /// Turns caps lock on/off and sets the state of the
        /// shift key accordingly
        /// </summary>
        /// <param name="onOff">true to turn on</param>
        private static void setCapsLockState(bool onOff)
        {
            const int KEYEVENTF_EXTENDEDKEY = 0x1;
            const int KEYEVENTF_KEYUP       = 0x2;

            if (onOff)
            {
                if (!Form.IsKeyLocked(Keys.CapsLock))
                {
                    // turn on capslock
                    User32Interop.keybd_event((byte)Keys.CapsLock, 0xAA, 0, UIntPtr.Zero);
                    User32Interop.keybd_event((byte)Keys.CapsLock, 0xAA, (uint)KEYEVENTF_KEYUP, UIntPtr.Zero);
                    turnOn(_shift);
                    _stickyShift = true;
                }
            }
            else
            {
                if (Form.IsKeyLocked(Keys.CapsLock))
                {
                    // turn off capslock
                    User32Interop.keybd_event((byte)Keys.CapsLock, 0x45, KEYEVENTF_EXTENDEDKEY, (UIntPtr)0);
                    User32Interop.keybd_event((byte)Keys.CapsLock, 0x45, KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP, (UIntPtr)0);
                    ClearShift();
                }
            }
        }