简体   繁体   中英

Sendkeys.send send alt+space+n combination

The title pretty much explains question. I want to sen alt+space+n combination via Senkeys.send method, how this could be done? So far I've tried SendKeys.Send("% N"); but it's not working.

Spacebar isn't a traditional modifier key, so I believe you will need to send the keyUp and keyDown events seperately.

I'm not completely familiar with C# sendkeys, since I use the AutoIt library for this kind of thing, with AutoIt the commands would be something like:

private void pressAltSpaceN()
{
   AutoItX3Declarations.AU3_Send("{alt down}", 0);
   AutoItX3Declarations.AU3_Send("{space down}", 0);
   AutoItX3Declarations.AU3_Send("{n down}", 0);
   AutoItX3Declarations.AU3_Send("{n up}", 0);
   AutoItX3Declarations.AU3_Send("{space up}", 0);
   AutoItX3Declarations.AU3_Send("{alt up}", 0);
}

Hopefully someone else can tell how to send keyUp and keyDown events using SendKeys, otherwise you can learn how to integrate AutoIt into C# using the answer to this question: link .

The string you're using should work. Perhaps the default journaling hook doesn't work with the application you're trying to minimize. You could try using the alternate method using app.config and SendInput (see here ).

A better way to solve the problem would be to obtain a handle to the focused window using GetActiveWindow , then call ShowWindowAsync and pass in a ShowWindowCommand value of 2.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM