本文整理汇总了C#中VirtualKeyCode类的典型用法代码示例。如果您正苦于以下问题:C# VirtualKeyCode类的具体用法?C# VirtualKeyCode怎么用?C# VirtualKeyCode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VirtualKeyCode类属于命名空间,在下文中一共展示了VirtualKeyCode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoKeyPress
public static void DoKeyPress(VirtualKeyCode aKey)
{
InputSimulator.SimulateKeyDown(aKey);
Thread.Sleep(200);
InputSimulator.SimulateKeyUp(aKey);
Thread.Sleep(200);
}
示例2: AsyncHoldKey
public static void AsyncHoldKey(VirtualKeyCode keycode)
{
if (InputSimulator.asyncHoldThread == null || !InputSimulator.asyncHoldThread.IsAlive)
{
InputSimulator.asyncHoldThread = new System.Threading.Thread( new System.Threading.ThreadStart(() =>
{
while (InputSimulator.currentAsyncHoldKeys.Count > 0)
{
lock (InputSimulator.currentAsyncHoldKeys)
{
foreach (VirtualKeyCode iter in InputSimulator.currentAsyncHoldKeys)
{
Console.WriteLine(iter);
WindowsInput.InputSimulator.SimulateKeyDown(iter);
}
}
System.Threading.Thread.Sleep(10);
}
}));
InputSimulator.asyncHoldThread.IsBackground = true;
InputSimulator.asyncHoldThread.Start();
}
currentAsyncHoldKeys.Add(keycode);
}
示例3: SimulateKeyPress
public static void SimulateKeyPress(VirtualKeyCode keyCode)
{
var down = new Input();
down.Type = (UInt32)InputType.KEYBOARD;
down.Data.Keyboard = new KeybdInput
{
Vk = (UInt16) keyCode,
Scan = 0,
Flags = 0,
Time = 0,
ExtraInfo = IntPtr.Zero
};
var up = new Input();
up.Type = (UInt32)InputType.KEYBOARD;
up.Data.Keyboard = new KeybdInput
{
Vk = (UInt16) keyCode,
Scan = 0,
Flags = (UInt32) KeyboardFlag.KEYUP,
Time = 0,
ExtraInfo = IntPtr.Zero
};
var inputList = new Input[2];
inputList[0] = down;
inputList[1] = up;
var numberOfSuccessfulSimulatedInputs = User32.SendInput(2, inputList, Marshal.SizeOf(typeof(Input)));
if (numberOfSuccessfulSimulatedInputs == 0) throw new Exception(string.Format("The key press simulation for {0} was not successful.", keyCode));
}
示例4: ModifierKey
public ModifierKey(VirtualKeyCode key, params VirtualKeyCode[] additional)
{
_key = key;
_additional = additional;
if(_additional == null)
_additional = new VirtualKeyCode[0];
}
示例5: UpKey
public static void UpKey(VirtualKeyCode keyCode)
{
if (Status.isKeyEnabled && InputSimulator.IsKeyDown(keyCode))
{
InputSimulator.SimulateKeyUp(keyCode);
}
}
示例6: GenerateCommand
public static Command GenerateCommand(InstructionData instruction)
{
VirtualKeyCode[] keys=new VirtualKeyCode[Values.GetLength(0)];
Values.CopyTo(keys, 0);
switch (instruction.commandType)
{
case InstructionData_CommandType.JOYSTICKAXIS:
return new Command(new JoystickCommandData(0,(JoystickDataType)instruction.axis,(short)instruction.value));
case InstructionData_CommandType.JOYSTICKBUTTON_PRESS:
return new Command(new JoystickCommandData(0, JoystickDataType.BUTTON_PRESS, 0, instruction.value));
case InstructionData_CommandType.JOYSTICKBUTTON_HOLD:
return new Command(new JoystickCommandData(0, JoystickDataType.BUTTON_HOLD, 0, instruction.value));
case InstructionData_CommandType.JOYSTICKBUTTON_RELEASE:
return new Command(new JoystickCommandData(0, JoystickDataType.BUTTON_RELEASE, 0, instruction.value));
case InstructionData_CommandType.KEYBOARD_PRESS:
return new Command(new KeyboardCommandData(keys[instruction.value], KeyboardCommandType.PRESS, instruction.control, instruction.shift));
case InstructionData_CommandType.KEYBOARD_HOLD:
return new Command(new KeyboardCommandData(keys[instruction.value], KeyboardCommandType.HOLD, instruction.control, instruction.shift));
case InstructionData_CommandType.KEYBOARD_RELEASE:
return new Command(new KeyboardCommandData(keys[instruction.value], KeyboardCommandType.RELEASE, instruction.control, instruction.shift));
}
return null;
}
示例7: PressKey
public static void PressKey(VirtualKeyCode keyCode)
{
if (Status.isKeyEnabled)
{
InputSimulator.SimulateKeyPress(keyCode);
}
}
示例8: KeyDown
/// <summary>
/// Эмулирует действие 'нажать и держать' над кнопкой.
/// </summary>
/// <param name="keyCode">
/// Ключ целевой кнопки.
/// </param>
public IKeyboard KeyDown(VirtualKeyCode keyCode)
{
this.logger.Info("Key down '{0}'", keyCode.ToString());
this.keyboardSimulator.KeyDown(keyCode);
Thread.Sleep(250);
return this;
}
示例9: KeyboardCommandData
public KeyboardCommandData(VirtualKeyCode key, KeyboardCommandType type, bool control = false, bool shift = false)
{
this.key = key;
this.type = type;
this.control = control;
this.shift = shift;
}
示例10: Set
public void Set(VirtualKeyCode key, KeyState keyState)
{
if(_modifierKeyState.ContainsKey(key))
_modifierKeyState[key] = keyState;
else
_modifierKeyState.Add(key, keyState);
}
示例11: DoBuff
public static void DoBuff(VirtualKeyCode aKey, bool aSelf)
{
Point OldMousePos = MouseGetPos();;
if (aSelf) CenterMouse();
DoSkill(aKey);
if (aSelf) MouseMove(OldMousePos);
}
示例12: ShiftSensitiveKey
public ShiftSensitiveKey(VirtualKeyCode keyCode, string normal, string modified, string displayText)
{
_keyCode = keyCode;
_normal = normal;
_modified = modified;
_displayText = displayText;
Display = !string.IsNullOrEmpty(_displayText) ? _displayText : _normal;
}
示例13: AddKeyInput
private void AddKeyInput(VirtualKeyCode keyCode, bool isKeyUp)
{
INPUT input = new INPUT();
input.Type = InputType.InputKeyboard;
input.Data.Keyboard = new KEYBDINPUT();
input.Data.Keyboard.wVk = keyCode;
if (isKeyUp) input.Data.Keyboard.dwFlags = KeyboardEventFlags.KEYEVENTF_KEYUP;
InputList.Add(input);
}
示例14: AsyncReleaseKey
public static void AsyncReleaseKey(VirtualKeyCode keycode)
{
lock (InputSimulator.currentAsyncHoldKeys)
{
InputSimulator.SimulateKeyUp(keycode);
InputSimulator.currentAsyncHoldKeys.RemoveAll(key => key.Equals(keycode));
}
}
示例15: MultiCharacterKey
public MultiCharacterKey(VirtualKeyCode keyCode, IList<string> keyDisplays) :
base(keyCode)
{
if (keyDisplays == null) throw new ArgumentNullException("keyDisplays");
if (keyDisplays.Count <= 0)
throw new ArgumentException("Please provide a list of one or more keyDisplays", "keyDisplays");
KeyDisplays = keyDisplays;
DisplayName = keyDisplays[0];
}