Keyboard icon indicating copy to clipboard operation
Keyboard copied to clipboard

Shift key handling

Open matosimi opened this issue 8 years ago • 1 comments

Hi, I like this project however I bumped into fact that it does not handle shift key properly... I am using it to send password characters (which obviously can contain capital letters and special characters that you type with shift key)... so this solution works well if you like to type "hello world3" however it does not work when you would like to type "Hello WoRLD#"... because capital letters will be replaced by normal ones...for the reason that this capitalization is somehow omitted in the code, yet it is quite prepared to support it... so here is my solution:

replace GetVirtualKeyCode method in Messaging.cs with following one:

public static uint GetVirtualKeyCode(char c, bool getShiftState = false)
{
 var helper = new Helper { Value = VkKeyScan(c) };
 byte virtualKeyCode = helper.Low;
 byte shiftState = helper.High;
 if (getShiftState)
  return shiftState;
 else return virtualKeyCode;
}

then replace Key(char c) constructor in Key.cs:

public Key(char c)
{
 _buttonCounter = 0; 
 Vk = (Messaging.VKeys)Messaging.GetVirtualKeyCode(c);
 ShiftKey = Messaging.VKeys.NULL;
 ShiftType = (Messaging.ShiftType)Messaging.GetVirtualKeyCode(c, true); 
}

...and suddenly Keyboard supports capital letters :)...and it can be tested with KeybordDemo right away.

matosimi avatar Aug 24 '17 16:08 matosimi

Put in a PR and I'll accept it

EasyAsABC123 avatar Aug 24 '17 16:08 EasyAsABC123