Home Dashboard Directory Help

vs2012 codedui keyboard.sendkeys using incorrect keyboard layout converts characters by Cram Pies


 as By Design Help for as By Design

Sign in
to vote
Type: Bug
ID: 794264
Opened: 7/17/2013 9:55:27 AM
Access Restriction: Public
User(s) can reproduce this bug


For more details see this forum post:

The test that has been screenshotted has send an @ via system.windows.forms.sendkeys.sendwait (works correctly)
Then it tries to send the same symbol via keyboard.sendkeys (works incorrectly).
Then it retries via system.windows.forms.sendkeys.sendwait (also works incorrectly).
This is demonstrating they keyboard.sendkeys mangling something inside.
This does not happen with vs2010.
It requires you to not be using a US keyboard layout.
Sign in to post a comment.
Posted by Cram Pies on 7/31/2013 at 5:47 AM
Hi Microsoft.
FYI, this behaviour is not present in vs2010 nor in vs2013 preview. Also the behaviour is different depending on which keyboard layout you currently have set.
Also if I send a "@" to sendkey I would expect a "@" to be 'typed' not a quotemark (") regardless of which keyboard layout I have selected.

Please reopen the bug and your mind.
Many thanks.
Posted by Microsoft on 7/31/2013 at 5:41 AM
Hi Cram Pies,
We investigated this issue and found this to be by design because
we load the current keyboard layout, and the argument passed to keyboard.sendkey will reflect the keys that would be typed out if user were to type it manually.

Based on this, I am closing this bug.
Posted by Cram Pies on 7/25/2013 at 7:04 AM
It would appear that the bug is not a simple case of CodedUI using the US keyboard layout for UK keyboards. I am currently working around this bug using the following code, however it doesn't resolve the ` char being converted to ':

string CodedUiBugReplace(string input)
    string newString = Regex.Replace(input, @"@|""|#|'|~", match =>
        switch (match.Value)
            case "@": return "~";
            case @"""": return "@";
            case "#": return "'";
            case "'": return "`";
            case "~": return "\"";
            default: throw new Exception("Unexpected match!");
    return newString;
Posted by Microsoft on 7/17/2013 at 9:51 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 7/17/2013 at 10:50 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
File Name Submitted By Submitted On File Size  
UploadSummary-130717165527.xml (restricted) 7/17/2013 -
VsInfo.xml (restricted) 7/17/2013 -
ScreenShot.jpg (restricted) 7/17/2013 -
DxDiagOutput.txt (restricted) 7/17/2013 -
ReproSteps.zip (restricted) 7/17/2013 -