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.
题目很好地解释了问题。我想通过Senkeys实现alt+空格+n组合。发送方法,如何做到这一点?到目前为止,我已经试过了SendKeys。发送(“% N”);但这不是工作。
2 个解决方案
#1
0
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:
我不完全熟悉c# sendkeys,因为我使用AutoIt库来做这种事情,使用AutoIt,命令会是:
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.
希望其他人能知道如何使用SendKeys发送keyUp和keyDown事件,否则您可以学习如何将AutoIt集成到c#中,使用这个问题的答案:link。
#2
0
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).
您正在使用的字符串应该有效。也许默认的日志钩子不能与要最小化的应用程序一起工作。您可以尝试使用app.config和SendInput替代方法(参见这里)。
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.
解决这个问题的一个更好的方法是,使用GetActiveWindow获得对焦点窗口的句柄,然后调用ShowWindowAsync并传入showwindow命令值2。
#1
0
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:
我不完全熟悉c# sendkeys,因为我使用AutoIt库来做这种事情,使用AutoIt,命令会是:
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.
希望其他人能知道如何使用SendKeys发送keyUp和keyDown事件,否则您可以学习如何将AutoIt集成到c#中,使用这个问题的答案:link。
#2
0
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).
您正在使用的字符串应该有效。也许默认的日志钩子不能与要最小化的应用程序一起工作。您可以尝试使用app.config和SendInput替代方法(参见这里)。
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.
解决这个问题的一个更好的方法是,使用GetActiveWindow获得对焦点窗口的句柄,然后调用ShowWindowAsync并传入showwindow命令值2。