diff --git a/src/GregsStack.InputSimulatorStandard/InputBuilder.cs b/src/GregsStack.InputSimulatorStandard/InputBuilder.cs index 7f093e3..3c4b4c5 100644 --- a/src/GregsStack.InputSimulatorStandard/InputBuilder.cs +++ b/src/GregsStack.InputSimulatorStandard/InputBuilder.cs @@ -20,6 +20,7 @@ internal class InputBuilder : IEnumerable private static readonly IReadOnlyList ExtendedKeys = new List { + VirtualKeyCode.NUMPAD_RETURN, VirtualKeyCode.MENU, VirtualKeyCode.RMENU, VirtualKeyCode.CONTROL, @@ -87,7 +88,7 @@ public InputBuilder() /// true if the key code is an extended key; otherwise, false. /// /// 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" /// public static bool IsExtendedKey(VirtualKeyCode keyCode) => ExtendedKeys.Contains(keyCode); @@ -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; diff --git a/src/GregsStack.InputSimulatorStandard/Native/VirtualKeyCode.cs b/src/GregsStack.InputSimulatorStandard/Native/VirtualKeyCode.cs index e880afc..f2f78ec 100644 --- a/src/GregsStack.InputSimulatorStandard/Native/VirtualKeyCode.cs +++ b/src/GregsStack.InputSimulatorStandard/Native/VirtualKeyCode.cs @@ -1,7 +1,7 @@ namespace GregsStack.InputSimulatorStandard.Native { /// - /// 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) /// public enum VirtualKeyCode { @@ -59,6 +59,11 @@ public enum VirtualKeyCode /// RETURN = 0x0D, + /// + /// Numeric keypad ENTER key + /// + NUMPAD_RETURN = 0x0D, + // 0x0E - 0x0F : Undefined /// @@ -785,7 +790,7 @@ public enum VirtualKeyCode // /// - /// 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 /// OEM_1 = 0xBA, @@ -810,12 +815,12 @@ public enum VirtualKeyCode OEM_PERIOD = 0xBE, /// - /// 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 /// OEM_2 = 0xBF, /// - /// 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 /// OEM_3 = 0xC0, diff --git a/tests/GregsStack.InputSimulatorStandard.Tests/InputBuilderTests.cs b/tests/GregsStack.InputSimulatorStandard.Tests/InputBuilderTests.cs index 2d1d017..57b922d 100644 --- a/tests/GregsStack.InputSimulatorStandard.Tests/InputBuilderTests.cs +++ b/tests/GregsStack.InputSimulatorStandard.Tests/InputBuilderTests.cs @@ -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)] diff --git a/tests/GregsStack.InputSimulatorStandard.Tests/InputSimulatorExamples.cs b/tests/GregsStack.InputSimulatorStandard.Tests/InputSimulatorExamples.cs index a7d5441..d56fb5a 100644 --- a/tests/GregsStack.InputSimulatorStandard.Tests/InputSimulatorExamples.cs +++ b/tests/GregsStack.InputSimulatorStandard.Tests/InputSimulatorExamples.cs @@ -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.")