Skip to content

Commit

Permalink
Add NUMPAD_RETURN for issue #27
Browse files Browse the repository at this point in the history
  • Loading branch information
Gh0stWalk3r committed Jan 7, 2020
1 parent 4e8c244 commit 9a2e22a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/GregsStack.InputSimulatorStandard/InputBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ internal class InputBuilder : IEnumerable<Input>

private static readonly IReadOnlyList<VirtualKeyCode> ExtendedKeys = new List<VirtualKeyCode>
{
VirtualKeyCode.NUMPAD_RETURN,
VirtualKeyCode.MENU,
VirtualKeyCode.RMENU,
VirtualKeyCode.CONTROL,
Expand Down Expand Up @@ -87,7 +88,7 @@ public InputBuilder()
/// <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 (CTRL+PAUSE) 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(VirtualKeyCode keyCode) => ExtendedKeys.Contains(keyCode);
Expand Down Expand Up @@ -210,7 +211,7 @@ public InputBuilder AddCharacter(char character)

// Handle extended keys:
// If the scan code is preceded by a prefix byte that has the value 0xE0 (224),
// we need to include the KEYEVENTF_EXTENDEDKEY flag in the Flags property.
// we need to include the KEYEVENTF_EXTENDEDKEY flag in the Flags property.
if ((scanCode & 0xFF00) == 0xE000)
{
down.Data.Keyboard.Flags |= (uint)KeyboardFlag.ExtendedKey;
Expand Down
13 changes: 9 additions & 4 deletions src/GregsStack.InputSimulatorStandard/Native/VirtualKeyCode.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace GregsStack.InputSimulatorStandard.Native
{
/// <summary>
/// The list of virtual key codes (see: http://msdn.microsoft.com/en-us/library/ms645540(VS.85).aspx)
/// The list of virtual key codes (see: https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes)
/// </summary>
public enum VirtualKeyCode
{
Expand Down Expand Up @@ -59,6 +59,11 @@ public enum VirtualKeyCode
/// </summary>
RETURN = 0x0D,

/// <summary>
/// Numeric keypad ENTER key
/// </summary>
NUMPAD_RETURN = 0x0D,

// 0x0E - 0x0F : Undefined

/// <summary>
Expand Down Expand Up @@ -785,7 +790,7 @@ public enum VirtualKeyCode
//

/// <summary>
/// Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ';:' key
/// Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the ';:' key
/// </summary>
OEM_1 = 0xBA,

Expand All @@ -810,12 +815,12 @@ public enum VirtualKeyCode
OEM_PERIOD = 0xBE,

/// <summary>
/// Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '/?' key
/// Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '/?' key
/// </summary>
OEM_2 = 0xBF,

/// <summary>
/// Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '`~' key
/// Used for miscellaneous characters; it can vary by keyboard. Windows 2000/XP: For the US standard keyboard, the '`~' key
/// </summary>
OEM_3 = 0xC0,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public void ReturnsIEnumerator()
public class IsExtendedKeyMethod : InputBuilderTests
{
[Theory]
[InlineData(VirtualKeyCode.NUMPAD_RETURN)]
[InlineData(VirtualKeyCode.MENU)]
[InlineData(VirtualKeyCode.RMENU)]
[InlineData(VirtualKeyCode.CONTROL)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void SayHello()
.Sleep(1000)
.TextEntry("notepad")
.Sleep(1000)
.KeyPress(VirtualKeyCode.RETURN)
.KeyPress(VirtualKeyCode.NUMPAD_RETURN)
.Sleep(1000)
.TextEntry("These are your orders if you choose to accept them...")
.TextEntry("This message will self destruct in 5 seconds.")
Expand Down

0 comments on commit 9a2e22a

Please sign in to comment.