Example #1
0
        private void _hook_KeyUp(object sender, CaptainHook.OpenTK.KeyboardKeyEventArgs e)
        {
            if (e.Key == Key.Space)
            {
                _sb.Clear();
                return;
            }

            if (e.Key == Key.BackSpace)
            {
                if (_sb.Length > 0)
                {
                    _sb.Remove(_sb.Length - 1, 1);
                }

                return;
            }

            if ((int)e.Key < 83 || (int)e.Key > 108)
            {
                return;
            }

            var timeSinceLastKey = DateTime.Now - _lastKeyEvent;

            _lastKeyEvent = DateTime.Now;

            if (timeSinceLastKey.TotalSeconds > 1)
            {
                _sb.Clear();
            }
            //we are continously typing
            _sb.Append(Enum.GetName(typeof(Key), e.Key));
            if (_sb.ToString().Equals("TRUMP"))
            {
                var keys = new List <Key>();
                for (int i = 0; i < _sb.Length; i++)
                {
                    keys.Add(Key.BackSpace);
                }
                keys.AddRange(new[] { Key.D, Key.U, Key.M, Key.B, Key.A, Key.S, Key.S });
                //we could generalize this and load from a dictionary.
                _hook.SendKeys(keys);
            }
            if (_sb.ToString().Equals("JAVASCRIPT"))
            {
                var keys = new List <Key>();
                for (int i = 0; i < _sb.Length; i++)
                {
                    keys.Add(Key.BackSpace);
                }
                keys.AddRange(new [] { Key.G, Key.A, Key.R, Key.B, Key.A, Key.G, Key.E });
                //we could generalize this and load from a dictionary.
                _hook.SendKeys(keys);
            }

            if (_sb.ToString().Equals("NODEJS"))
            {
                var keys = new List <Key>();
                for (int i = 0; i < _sb.Length; i++)
                {
                    keys.Add(Key.BackSpace);
                }
                keys.AddRange(new[] { Key.C, Key.G, Key.I });
                //we could generalize this and load from a dictionary.
                _hook.SendKeys(keys);
            }
        }
Example #2
0
 private void _hook_KeyDown(object sender, CaptainHook.OpenTK.KeyboardKeyEventArgs e)
 {
     //i'm just going to watch the keyup event
 }