This is a migrated thread and some comments may be shown as answers.

Can't Combine shift key down with other keys

1 Answer 156 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ray
Top achievements
Rank 1
Ray asked on 08 Mar 2011, 04:53 PM
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

1 Answer, 1 is accepted

Sort by
0
Ray
Top achievements
Rank 1
answered on 08 Mar 2011, 06:47 PM
Got it working with

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

Tags
General Discussions
Asked by
Ray
Top achievements
Rank 1
Answers by
Ray
Top achievements
Rank 1
Share this question
or