本文整理汇总了C#中VirtualKey类的典型用法代码示例。如果您正苦于以下问题:C# VirtualKey类的具体用法?C# VirtualKey怎么用?C# VirtualKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VirtualKey类属于命名空间,在下文中一共展示了VirtualKey类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsLetter
public static bool IsLetter(VirtualKey key)
{
switch (key)
{
case VirtualKey.A:
case VirtualKey.B:
case VirtualKey.C:
case VirtualKey.D:
case VirtualKey.E:
case VirtualKey.F:
case VirtualKey.G:
case VirtualKey.H:
case VirtualKey.I:
case VirtualKey.J:
case VirtualKey.K:
case VirtualKey.L:
case VirtualKey.M:
case VirtualKey.N:
case VirtualKey.O:
case VirtualKey.P:
case VirtualKey.Q:
case VirtualKey.R:
case VirtualKey.S:
case VirtualKey.T:
case VirtualKey.U:
case VirtualKey.V:
case VirtualKey.W:
case VirtualKey.X:
case VirtualKey.Y:
case VirtualKey.Z:
case VirtualKey.Space:
return true;
}
return false;
}
示例2: ToChar
private static char? ToChar(VirtualKey key, bool shift)
{
// convert virtual key to char
if (32 == (int)key)
return ' ';
VirtualKey search;
// look for simple letter
foreach (var letter in "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
{
if (Enum.TryParse<VirtualKey>(letter.ToString(), out search) && search.Equals(key))
return (shift) ? letter : letter.ToString().ToLower()[0];
}
// look for simple number
foreach (var number in "1234567890")
{
if (Enum.TryParse<VirtualKey>("Number" + number.ToString(), out search) && search.Equals(key))
return number;
}
// not found
return null;
}
示例3: KeyInput
public KeyInput(IntPtr hkl, VirtualKey virtualKey)
{
this.m_sc = NativeMethods.MapVirtualKeyExWrapper((uint)virtualKey, MapVirtualKeyMapTypes.MAPVK_VK_TO_VSC_EX, hkl);
this.m_hkl = hkl;
this.m_vk = (uint)virtualKey;
InterrogateKeyboardLayout(this.m_hkl, this.m_vk, this.m_sc);
}
示例4: Input
//not sure if I like this pattern
public void Input(VirtualKey keypress)
{
if (keyWaiter != null)
{
keyWaiter.TrySetResult(keypress);
}
}
示例5: IsNumeric
public static bool IsNumeric(VirtualKey key, bool checkModifiers = true)
{
if (checkModifiers && Window.Current.CoreWindow.GetKeyState(VirtualKey.Shift).HasFlag(CoreVirtualKeyStates.Down))
return false;
switch (key)
{
case VirtualKey.NumberPad0:
case VirtualKey.NumberPad1:
case VirtualKey.NumberPad2:
case VirtualKey.NumberPad3:
case VirtualKey.NumberPad4:
case VirtualKey.NumberPad5:
case VirtualKey.NumberPad6:
case VirtualKey.NumberPad7:
case VirtualKey.NumberPad8:
case VirtualKey.NumberPad9:
case VirtualKey.Number0:
case VirtualKey.Number1:
case VirtualKey.Number2:
case VirtualKey.Number3:
case VirtualKey.Number4:
case VirtualKey.Number5:
case VirtualKey.Number6:
case VirtualKey.Number7:
case VirtualKey.Number8:
case VirtualKey.Number9:
return true;
}
return false;
}
示例6: IsHolding
public bool IsHolding( VirtualKey K )
{
if( HoldingKeys.ContainsKey( K ) )
return HoldingKeys[ K ];
return false;
}
示例7: IsValidHexDigitKey
public static bool IsValidHexDigitKey(VirtualKey key)
{
bool ret = (key >= VirtualKey.Number0 && key <= VirtualKey.Number9) ||
(key >= VirtualKey.A && key <= VirtualKey.F);
return ret;
}
示例8: ToUnicodeEx
public static extern int ToUnicodeEx(
uint wVirtKey,
uint wScanCode,
VirtualKey[] lpKeyState,
StringBuilder pwszBuff,
int cchBuff,
uint wFlags,
IntPtr dwhkl);
示例9: IsNumberKey
private bool IsNumberKey(VirtualKey inKey)
{
if (inKey < VirtualKey.Number0 || inKey > VirtualKey.Number9 && inKey < VirtualKey.NumberPad0 || inKey > VirtualKey.NumberPad9)
{
return false;
}
return true;
}
示例10: MakeKeyboardSendKeyEventCommand
public static string MakeKeyboardSendKeyEventCommand(VirtualKey key)
{
var args = new KeyboardSendKeyEventArgs()
{
Key = key,
};
var argsSerialize = JsonConvert.SerializeObject(args);
return PluginCommandSerializeMaker.MakeCommand(InnerPluginName, "KeyboardSendKeyEvent", argsSerialize);
}
示例11: KeyBind
public KeyBind(VirtualKey mainKey,string commandCode)
{
this.MainKey = mainKey;
IsMainKeyOnly = true;
IsOptionKeyDown = false;
IsCallBackOn = false;
this.CommandCode = commandCode;
}
示例12: KeyDown
public void KeyDown(VirtualKey vk)
{
switch (vk)
{
case VirtualKey.Enter:
if (Select != null) { Select(); }
break;
}
}
示例13: KeyPress
/// <summary>
/// Calls the Win32 SendInput method with a KeyDown and KeyUp message in the same input sequence in order to simulate a Key PRESS.
/// </summary>
/// <param name="keyCode">The <see cref="VirtualKey"/> to press</param>
public void KeyPress(VirtualKey keyCode)
{
var inputList =
new InputBuilder()
.AddKeyDown(keyCode)
.AddKeyUp(keyCode)
.ToArray();
SendSimulatedInput(inputList);
}
示例14: SetVirtualKey
public static void SetVirtualKey(string keyName, float sensitivity = 3f, float gravity = 3f, float deadZone = 0.01f) {
if(LookupVirtualKeyIndex(keyName) != -1) {
Debug.LogWarning("That key is already defined: (" + keyName + ")");
return;
}
int index = GetFirstOpenKeySpot();
virtualKeys[index] = new VirtualKey(keyName, sensitivity, gravity, deadZone);
virtualKeysStaged[index] = new VirtualKey(keyName, sensitivity, gravity, deadZone);
virtualKeyIndexers.Add(index);
}
示例15: MakeKeyboardEventCommand
public static string MakeKeyboardEventCommand(VirtualKey key, byte scan, uint flag, uint extraInfo)
{
var args = new KeyboardEventArgs()
{
Key = key,
ScanKey = scan,
Flag = flag,
ExtraInfo = extraInfo,
};
var argsSerialize = JsonConvert.SerializeObject(args);
return PluginCommandSerializeMaker.MakeCommand(InnerPluginName, "KeyboardEvent", argsSerialize);
}