Desktop.Robot
Desktop.Robot copied to clipboard
Add support for different case of text and modifiers when using the Type function
I want to send the keypresses for the string "This is a test!" but it turns into "this is a test1". I'm assuming the letters are reduced to their respective key and the modifiers aren't kept. So "T" becomes "t" and "!" becomes "1" because the "!" characters is a modifier of the "1" button on my keyboard. (Norwegian)
I tried to use robot.CombineKeys(Key.Shift, Key.T);
to get the upper case T, which worked, but it would be nice if the Type()
function handled that for me.
The exclamation point didn't work with robot.CombineKeys(Key.Shift, Key.One);
tho. For some reason it printed "Z" to me..
Sorry for delaying on reply. What SO are you using?
By the way, I think you're using the wrong function. CombineKeys may works, but this method is not supposed to do what you want. Try using this overload of Type funcion:
robot.Type(Key.Shift, Key.T); https://github.com/lucassklp/Desktop.Robot/blob/main/Desktop.Robot/Extensions/TypingExtension.cs#L30
Regarding the problem related to Shift + 1, I'll check it out!
In Keys.cs windows Keycode for numbers Zero to Nine are all 0x5A same as 'Z', should be 0x30 - 0x39.
...
[Keycode(Platform = "OSX", Keycode = 0x06)]
[Keycode(Platform = "Windows", Keycode = **0x5A**)]
[Keycode(Platform = "Linux", Keycode = 0x007a)]
Z,
//Numbers
[Keycode(Platform = "OSX", Keycode = 0x30)]
[Keycode(Platform = "Windows", Keycode = **0x5A**)]
[Keycode(Platform = "Linux", Keycode = 0x0030)]
Zero,
Try using this overload of Type funcion:
robot.Type(Key.Shift, Key.T);
I don't think that would work, it'll just press shift and then t without holding shift. CombineKeys
is the correct method to use for that.
@EightNetNz This PR fixes that