コード例 #1
0
        private void AddKeyDown(WindowsAPI.VirtualKeyCode keyCode)
        {
            var key = new WindowsAPI.Input {
                Type = WindowsAPI.InputType.Keyboard,
                Data =
                {
                    Keyboard      = new WindowsAPI.KeyboardInput {
                        KeyCode   = (UInt16)keyCode,
                        Scan      = 0,
                        Flags     = 0,
                        Time      = 0,
                        ExtraInfo = IntPtr.Zero
                    }
                }
            };

            _input.Add(key);
        }
コード例 #2
0
        public KeyInput RemoveItem(int index)
        {
            var  current      = 0;
            var  downKeyIndex = 0;
            var  upKeyIndex   = 0;
            bool downFound    = false;

            for (int i = 0; i < _input.Count; i++)
            {
                if (_input[i].Data.Keyboard.Flags == 0 && !downFound)
                {
                    if (index == current)
                    {
                        downKeyIndex = i;
                        downFound    = true;
                    }
                    current++;
                }
                else if (_input[i].Data.Keyboard.Flags != 0 && downFound)
                {
                    if (_input[i].Data.Keyboard.KeyCode == _input[downKeyIndex].Data.Keyboard.KeyCode)
                    {
                        upKeyIndex = i;
                        break;
                    }
                }
            }

            WindowsAPI.Input downKey = _input[downKeyIndex];
            WindowsAPI.Input upKey   = _input[upKeyIndex];

            _input.Remove(downKey);
            _input.Remove(upKey);

            return(this);
        }