Is there anyway that I can find out if user has been holding Shift (CTRL or any other key) when she/he double click on application icon from desktop to start the application?
I have a WPF application where I want to be able to detect if the user has b开发者_Go百科een holding any special key when he/she started the application (by double clicking) so I can change some settings if the key was pressed.
I tried :
private void Application_Startup(object sender, StartupEventArgs e)
{
}
but couldn't find any way to detect the key down .
Write this code in your application start-up event:
// Instead of the MessageBox you could write your code here
if ((Keyboard.Modifiers & ModifierKeys.Shift) > 0)
{
MessageBox.Show("Shift Pressed");
}
I think you should look at this question: Keyboard modifiers during application startup This is probably what you're looking for.
Hope it helps.
精彩评论