コード例 #1
0
 public KeyProperties(SBC.Key a, SBC.Key b, bool c)//used when we have a modifier
 {
     modifier    = a;
     keyCode1    = b;
     holdDown    = c;
     useModifier = true;
 }
コード例 #2
0
 public KeyProperties(SBC.Key a, bool b)
 {
     modifier    = (SBC.Key)(0);
     keyCode1    = a;
     holdDown    = b;
     useModifier = false;
 }
コード例 #3
0
 public static void SimulateModifiedKeyStroke(SBC.Key modifier, SBC.Key keycode)
 {
     SimulateKeyDown(modifier);
     SimulateKeyDown(keycode);
     System.Threading.Thread.Sleep(ModifiedKeyStrokeDelay);
     SimulateKeyUp(keycode);
     SimulateKeyUp(modifier);
 }
コード例 #4
0
 public void AddButtonKeyMapping(ButtonEnum button, SBC.Key keyCode, bool holdDown)
 {
     if (ButtonKeys.Contains((int)button))
     {
         ButtonKeys.Remove((int)button);//to save on later garbage collection
     }
     ButtonKeys[(int)button] = new KeyProperties(keyCode, holdDown);
 }
コード例 #5
0
 public static void SimulateModifiedKeyStroke(SBC.Key[] modifierKeyCodes, SBC.Key keycode)
 {
     foreach (SBC.Key k in modifierKeyCodes)
     {
         SimulateKeyDown(k);
     }
     SimulateKeyDown(keycode);
     System.Threading.Thread.Sleep(ModifiedKeyStrokeDelay);
     SimulateKeyUp(keycode);
     foreach (SBC.Key k in modifierKeyCodes)
     {
         SimulateKeyUp(k);
     }
 }
コード例 #6
0
        public static void SimulateKeyUp(SBC.Key key)
        {
            INPUT structure = new INPUT();

            structure.type = (int)InputType.INPUT_KEYBOARD;
            //structure.ki.wVk = VkKeyScan((char)key);
            structure.ki.wScan = (ushort)key;
            if (IsExtendedKey(key))
            {
                structure.ki.dwFlags = (uint)((int)KEYEVENTF.KEYUP | (uint)KEYEVENTF.SCANCODE | (uint)KEYEVENTF.EXTENDEDKEY);
            }
            else
            {
                structure.ki.dwFlags = (uint)((int)KEYEVENTF.KEYUP | (uint)KEYEVENTF.SCANCODE);
            }
            structure.ki.time        = 0;
            structure.ki.dwExtraInfo = GetMessageExtraInfo();

            INPUT[] pInputs = new INPUT[] { structure };

            SendInput(1, pInputs, Marshal.SizeOf(structure));
        }
コード例 #7
0
        public static int ModifiedKeyStrokeDelay = 5;//number of milliseconds combination keys will be held down.
        //this number was experimentally found out as the minimum necessary for MW4 to respond to modified
        //keystroke

        /// <summary>
        /// Determines if the <see cref="VirtualKeyCode"/> is an ExtendedKey
        /// </summary>
        /// <param name="keyCode">The key code.</param>
        /// <returns>true if the key code is an extended key; otherwise, false.</returns>
        /// <remarks>
        /// The extended keys consist of the ALT and CTRL keys on the right-hand side of the keyboard; the INS, DEL, HOME, END, PAGE UP, PAGE DOWN, and arrow keys in the clusters to the left of the numeric keypad; the NUM LOCK key; the BREAK (CTRLPAUSE) key; the PRINT SCRN key; and the divide (/) and ENTER keys in the numeric keypad.
        ///
        /// See http://msdn.microsoft.com/en-us/library/ms646267(v=vs.85).aspx Section "Extended-Key Flag"
        /// </remarks>
        public static bool IsExtendedKey(SBC.Key keyCode)
        {
            //issue with backspace originated here, it should have not been on the extended list.
            if (
                keyCode == SBC.Key.Insert ||
                keyCode == SBC.Key.Delete ||
                keyCode == SBC.Key.Home ||
                keyCode == SBC.Key.End ||
                keyCode == SBC.Key.Prior ||
                keyCode == SBC.Key.Next ||
                keyCode == SBC.Key.Right ||
                keyCode == SBC.Key.Up ||
                keyCode == SBC.Key.Left ||
                keyCode == SBC.Key.Down ||
                keyCode == SBC.Key.Numlock ||
                keyCode == SBC.Key.Divide)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #8
0
 public void sendKeyUp(SBC.Key keycode)
 {
     InputSimulator.SimulateKeyUp(keycode);
 }
コード例 #9
0
 public void sendKeyPress(SBC.Key modifier, SBC.Key keycode)
 {
     InputSimulator.SimulateModifiedKeyStroke(modifier, keycode);
 }
コード例 #10
0
 public void AddButtonKeyMapping(ButtonEnum button, SBC.Key modifier, SBC.Key keyCode, bool holdDown)
 {
     ButtonKeys[(int)button] = new KeyProperties(modifier, keyCode, holdDown);
 }
コード例 #11
0
 public void AddButtonKeyLightMapping(ButtonEnum button, bool lightOnHold, int intensity, SBC.Key keyCode1, SBC.Key keyCode2, bool holdDown)
 {
     AddButtonLightMapping(button, lightOnHold, intensity);
     AddButtonKeyMapping(button, keyCode1, keyCode2, holdDown);
 }
コード例 #12
0
 public static void SimulateKeyPress(SBC.Key key)
 {
     SimulateKeyDown(key);
     SimulateKeyUp(key);
 }