过程C#的WinForms按钮按键? [英] Process c# winforms button as keystroke?
问题描述
我要按下时,使上一个按钮,组合键<大骨节病>控制骨节病> + <大骨节病> + 骨节病>被按下,另一个其中<大骨节病>控制骨节病> + <大骨节病> - 骨节病>被按下。我如何才能做到这一点。
下面是你想要的一个可能的解决方案:
//按钮创建
键则myButton =新按钮();
myButton.Click + = myButton_Click;
然后在事件 myButton_Click();
无效myButton_Click(对象发件人,EventArgs五)
{
SendKeys.Send(^({ ADD}))
}
然后,您可以做类似的 - 键,选中的这里的关键符号使用
修改
另一个变化是这样做,而不是:
无效myButton_Click(对象发件人,EventArgs五)
{
SendKeys.Send(^({+}))
}
<块引用>
加号(+),插入符号(^),百分号(%),波形符(〜)以及括号()有特殊含义的SendKeys。要指定这些字符之一,大括号括起来({})。例如,要指定加号,请使用{+}
块引用>
来源:
I want to make a button on that when pressed, the key combination Ctrl + + is pressed and another where Ctrl + - is pressed. How can I achieve this?
Here is a possible solution for what you want:
//Button creation
Button myButton= new Button();
myButton.Click += myButton_Click;
Then in the event myButton_Click();
void myButton_Click(object sender, EventArgs e)
{
SendKeys.Send("^({ADD})")
}
You can then do similar for the - key, check here for the key symbols to use
EDIT
The other variation is to do this instead:
void myButton_Click(object sender, EventArgs e)
{
SendKeys.Send("^({+})")
}
The plus sign (+), caret (^), percent sign (%), tilde (~), and parentheses () have special meanings to SendKeys. To specify one of these characters, enclose it within braces ({}). For example, to specify the plus sign, use "{+}".
Sources:
Trigger a keyboard key press event without pressing the key from keyboard
这篇关于过程C#的WinForms按钮按键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!