user1563221
user1563221

Reputation: 391

How to use windows key in a WPF Application

According to this question, I tried to use windows key inside my WPF application. But, it didn't work! Here is my code

case "My Computer":
DeviceSpeak.Speak("Opening My Computer");
SendKeys.SendWait("{Key.LWin}E");
break;

My question is how to use windows key in C#. I want to open my computer(WindwosKey+E).

Upvotes: 2

Views: 445

Answers (2)

Adnan
Adnan

Reputation: 8729

You can find more information about CLSID here and a hope quick Google search will help you a lot.

Upvotes: 0

max
max

Reputation: 34407

I don't think there is a way to simulate WIN key press using SendKeys. Anyway, you can open special locations using their CLSIDs:

// open "My Computer"
System.Diagnostics.Process.Start("::{20d04fe0-3aea-1069-a2d8-08002b30309d}");

Some more CLSIDs (some might not work):

Administrative Tools: {D20EA4E1-3957-11d2-A40B-0C5020524153}
All Tasks:            {ED7BA470-8E54-465E-825C-99712043E01C}
Control Panel:        {21EC2020-3AEA-1069-A2DD-08002b30309d}
Connections:          {241D7C96-F8BF-4F85-B01F-E2B043341A4B}
Fonts:                {D20EA4E1-3957-11d2-A40B-0C5020524152}
Computer:             {20D04FE0-3AEA-1069-A2D8-08002B30309D}
Documents:            {450D8FBA-AD25-11D0-98A8-0800361B1103}
History:              {ff393560-c2a7-11cf-bff4-444553540000}
Network Places:       {208d2c60-3aea-1069-a2d7-08002b30309d}
Printers and Faxes:   {2227A280-3AEA-1069-A2DE-08002B30309D}
Programs Folder:      {7be9d83c-a729-4d97-b5a7-1b7313c39e0a}
Recycle Bin:          {645FF040-5081-101B-9F08-00AA002F954E}
Start Menu:           {48e7caab-b918-4e58-a94d-505519c795dc}
Scheduled Tasks:      {D6277990-4C6A-11CF-8D87-00AA0060F5BF}

Upvotes: 3

Related Questions