开发者

detecting if shift was held when application started

开发者 https://www.devze.com 2023-02-14 03:36 出处:网络
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?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消