自己的程序部分 注释也打不上来多少,因为自己对核心概念也说不清楚嗷嗷嗷 /./
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Timers;
namespace WindowsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.KeyUp += new KeyEventHandler(this.Form1_KeyUp); //键盘事件
}
private System.Timers.Timer timerClock = new System.Timers.Timer();
public void OnTimer(Object source, ElapsedEventArgs e) //鼠标点击模拟,由时间事件引发
{
const int MOUSEEVENTF_MOVE = 0x0001; // 移动鼠标
const int MOUSEEVENTF_LEFTDOWN = 0x0002;// 模拟鼠标左键按下
const int MOUSEEVENTF_LEFTUP = 0x0004;// 模拟鼠标左键抬起
const int MOUSEEVENTF_RIGHTDOWN = 0x0008; //模拟鼠标右键按下
const int MOUSEEVENTF_RIGHTUP = 0x0010;// 模拟鼠标右键抬起
const int MOUSEEVENTF_MIDDLEDOWN = 0x0020;// 模拟鼠标中键按下
const int MOUSEEVENTF_MIDDLEUP = 0x0040; //模拟鼠标中键抬起
const int MOUSEEVENTF_ABSOLUTE = 0x8000;// 标示是否采用绝对坐标
// mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, 500, 500, 0, 0);
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
// MessageBox.Show("test","test");
}
private void button1_Click(object sender, EventArgs e) //这个是前期测试的一部分 后面直接留作按钮启动timer的方法
{
timerClock.Enabled = false;
timerClock.Elapsed += new ElapsedEventHandler(OnTimer);
timerClock.Interval =this.trackBar1.Value*1000;
timerClock.Enabled = true;
}
private void Form1_KeyUp(object sender, KeyEventArgs e) //按键事件
{
if (e.Control && e.KeyCode == Keys.P)
{
if (timerClock.Enabled == false)
{
timerClock.Elapsed += new ElapsedEventHandler(OnTimer);
timerClock.Interval = this.trackBar1.Value * 1000;
timerClock.Enabled = true;
}
else timerClock.Enabled = false;
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void trackBar1_Scroll(object sender, EventArgs e) //拉条 (- - 是拉条么._)选择间隔时间,显示出来
{
this.label1.Text=this.trackBar1.Value.ToString()+"秒";
}
private void label1_Click(object sender, EventArgs e)
{
}
}
}