- kven
-
引用命名空间using System.Threading;
下面是窗体的二个事件,和鼠标按住时的方法,很简单
bool isMoseDown = true;
private void Test()
{
int i = 0;
while (isMoseDown)
{
this.BeginInvoke(new MethodInvoker(delegate
{
textBox1.Text = (i++).ToString();
}));
Thread.Sleep(200);
}
}
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
isMoseDown = true;
Thread td = new Thread(new ThreadStart(Test));
td.IsBackground = true;
td.Start();
}
}
private void Form1_MouseUp(object sender, MouseEventArgs e)
{
isMoseDown = false;
}
或者:
bool isMoseDown = true;
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
isMoseDown = true;
int i = 0;
while (isMoseDown)
{
textBox1.Text = (i++).ToString();
Application.DoEvents();
Thread.Sleep(200);
}
}
}
private void Form1_MouseUp(object sender, MouseEventArgs e)
{
isMoseDown = false;
}
- 左迁
-
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
private bool bContinue = false;
private int i = 0;
public Form1()
{
InitializeComponent();
}
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
bContinue = true;
while (bContinue)
{
this.Form1_Click(this, EventArgs.Empty);
System.Threading.Thread.Sleep(200);
Application.DoEvents();
}
}
}
private void Form1_MouseUp(object sender, MouseEventArgs e)
{
bContinue = false;
}
private void Form1_Click(object sender, EventArgs e)
{
this.listBox1.Items.Add(i++);
}
}
}
这个能实现在本窗体按住鼠标左键就相当于连击
- echo
-
画面添加label1 和 timer1
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
long lngaaa = 0;
public Form1()
{
InitializeComponent();
label1.Text = "0";
timer1.Interval = 50;
}
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
timer1.Enabled = true;
}
}
private void Form1_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
timer1.Enabled = false;
}
}
private void timer1_Tick(object sender, EventArgs e)
{
lngaaa = lngaaa + 1;
label1.Text = Convert.ToString(lngaaa);
}
}
}
兄弟 你说的这钟情况你还是去下一个按键精灵吧!~ 以前玩游戏的时候就用那个玩意~
- 猫帽
-
这需要调用鼠标操作
还得不停的监视鼠标是否按下
所以鼠标事件神马的都不行,因为那是检测有焦点,而且是在控件上的鼠标操作
想鼠标连击 最快的方法是按键精灵
- 真可云
-
你说的连击是什么意思?
在用C#编写winform程序时,你可以看一下这三个事件:MouseDown、MouseUp、MouseMove三个事件。如果不太明白我说的是什么可以再问我。