コード例 #1
0
        public List <int> WhichModifiersPressed(int flags)
        {
            List <int> pressedModifiers = new List <int>();

            int[] modifierKeys =
            {
                KeyMapConverter.KeyToCode(OriginalKey.LeftWindows),
                KeyMapConverter.KeyToCode(OriginalKey.RightWindows),
                KeyMapConverter.KeyToCode(OriginalKey.LeftCtrl),
                KeyMapConverter.KeyToCode(OriginalKey.RightCtrl),
                KeyMapConverter.KeyToCode(OriginalKey.LeftShift),
                KeyMapConverter.KeyToCode(OriginalKey.RightShift),
            };

            for (int i = 0; i < modifierKeys.Length; i++)
            {
                var mk = modifierKeys[i];
                if (GetAsyncKeyState(mk) < 0)
                {
                    pressedModifiers.Add(mk);
                }
            }

            //Logger.WriteLine($"InterceptKeyboard.WhichModifierPressed.flags = {flags}");

            // ALT は左右の判定ができないので左ALTが押されたものとする
            // flags の値は、キーダウン時は 32(0x20)、キーアップ時は160(0xA0)
            if ((flags & 0x20) == 0x20)
            {
                pressedModifiers.Add(KeyMapConverter.KeyToCode(OriginalKey.LeftAlt));
                //pressedModifiers.Add(KeyMapConverter.KeyToCode(OriginalKey.RightAlt));
            }

            return(pressedModifiers);
        }
コード例 #2
0
        /// <summary>
        /// Input the Key.
        /// </summary>
        /// <param name="pushedKey">Actually pushed key</param>
        /// <param name="destKey">Converted key</param>
        /// <returns></returns>
        protected IntPtr InputKey(OriginalKey pushedKey, OriginalKey destKey)
        {
            var inputKey = KeyMapConverter.KeyToCode(destKey);
            var inkey    = input.KeyDown(inputKey);

            if (!inkeys.ContainsKey(pushedKey))
            {
                inkeys.Add(pushedKey, inkey);
            }
            return(new IntPtr(1));
        }