How to press the Windows button programmatically using C# SendKeys

前端 未结 3 1439
故里飘歌
故里飘歌 2021-01-12 04:02

Basically I want to simulate in code a user clicking on the windows button. I know there is SendKeys which allows me to send key presses to windows if I get a handle to them

3条回答
  •  走了就别回头了
    2021-01-12 05:08

    I don't think you can do this using SendKeys, you will need to p/invoke to an API function instead, probably keybd_event to send either CTRL+ESC or the Windows key.

    Here is an example of opening the start menu this way in VB and here is keybd_event with its C# signature on pinvoke.net.

提交回复
热议问题