Can't Combine shift key down with other keys

2 posts, 0 answers
  1. Ray
    Ray avatar
    2 posts
    Member since:
    Mar 2011

    Posted 08 Mar 2011 Link to this post

    I'm trying to press Shift+Home on my control, I've tried a few things, but the control always interprets the key presses as if the shift key wasn't pushed (i.e. it still acts on the Home key, but not as if shift was pushed). The control works fine in manual testing.

    The weird thing is, if at any point I stop the code between the shift key down and the shift key up, then the shift key is definitely pushed as every program in Windows acts like it is, even the program I'm trying to test.
    Here's what I've tried:
    1)*
    myFrameworkElement.User.KeyDown(Keys.ShiftKey);
    myFrameworkElement.User.KeyPress(Keys.Home);
    myFrameworkElement.User.KeyUp(Keys.ShiftKey);
    2)
    myFrameworkElement.User.KeyPress(Keys.ShiftKey | Keys.Home);
    3)**
    silverlightApp.Desktop.KeyBoard.KeyDown(Keys.ShiftKey);
    silverlightApp.Desktop.KeyBoard.KeyPress(Keys.Home);
    silverlightApp.Desktop.KeyBoard.KeyUp(Keys.ShiftKey);
    4)
    silverlightApp.Desktop.KeyBoard.KeyPress(Keys.ShiftKey | Keys.Home);
    5)
    var keys = Keyboard.KeysFromString("Shift+Home");
    silverlightApp.Desktop.KeyBoard.KeyPress(keys);

    Any help on how to accomplish this would be great.

    * myFrameworkElement is ArtOfTest.WebAii.Silervlight.FrameworkElement
    **silverlightApp is ArtOfTest.WebAii.Silervlight.SilverlightApp
  2. Ray
    Ray avatar
    2 posts
    Member since:
    Mar 2011

    Posted 08 Mar 2011 Link to this post

    Got it working with

    silverlightApp.Desktop.KeyBoard.SendString("+{Home}");

Back to Top