Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NUMPAD_RETURN for issue #27 #32

Merged
merged 1 commit into from
Feb 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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