好的,所以我想做什么,当鼠标处于HELD DOWN状态时,我希望它能够连续按下一个键。它应该不断按下这个键直到我放开。
想象一下,如果你愿意,在Windows窗体上有一个左右按钮, 然后通过单击并按住右键,文本框中的字母“R”将一直显示,直到您松开按钮。我正在做的事与这种情况没什么关系,但是你得到了我在这里想要做的事情。
在没有锁定应用程序的情况下,我将鼠标放在哪里以保持sendkeys永远存在?
我希望我的问题有道理。洛尔。
由于
RT
private void pictureBoxKeyboard_MouseDown(object sender, MouseEventArgs e)
{
//something goes here
}
答案 0 :(得分:1)
值得一读...
http://msdn.microsoft.com/en-us/library/ms171548.aspx
SendKeys.Send(" R&#34)
这可能只会触发一次,您可能需要附加一个在MouseDown事件上启动并在MouseUp事件上停止的计时器。然后你可以把SendKeys放在Timer.Tick事件中。
private void Form1_Load(object sender, EventArgs e)
{
this.timer1.Interval = 500;
}
private void button1_MouseUp(object sender, MouseEventArgs e)
{
timer1.Stop();
this.Text = "moose-Up";
}
private void button1_MouseDown(object sender, EventArgs e)
{
timer1.Start();
this.Text = "moose-Down";
this.richTextBox1.Select();
}
private void timer1_Tick(object sender, EventArgs e)
{
SendKeys.Send("r");
Debug.Print("tickling");
}
选择您希望收到SendKeys值的控件...