using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace AutoKeyTool{ public partial class FrmMain : Form { KeyboardHook kh; public FrmMain() { InitializeComponent(); } private void btnStart_Click(object sender, EventArgs e) { this.timerClick.Enabled = true; } private void timerClick_Tick(object sender, EventArgs e) { MouseHook.MouseClick(); if (this.cbEnter.Checked) { SendKeys.Send("{ENTER}"); //模拟键盘输入ENTER } } private void btnPouse_Click(object sender, EventArgs e) { this.timerClick.Enabled = false; } private void FrmMain_Load(object sender, EventArgs e) { kh = new KeyboardHook(); kh.SetHook(); kh.OnKeyDownEvent = kh_OnKeyDownEvent; } void kh_OnKeyDownEvent(object sender, KeyEventArgs e) { //if (e.KeyData == (Keys.S | Keys.Control)) { this.Show(); }//Ctrl S显示窗口 //if (e.KeyData == (Keys.H | Keys.Control)) { this.Hide(); }//Ctrl H隐藏窗口 //if (e.KeyData == (Keys.C | Keys.Control)) { this.Close(); }//Ctrl C 关闭窗口 //Ctrl F11 开始点击 if (e.KeyData == (Keys.F11 | Keys.Control)) { this.timerClick.Enabled = true; } //Ctrl F12 暂停点击 if (e.KeyData == (Keys.F12 | Keys.Control)) { this.timerClick.Enabled = false; } } private void FrmMain_FormClosed(object sender, FormClosedEventArgs e) { kh.UnHook(); } private void FrmMain_Shown(object sender, EventArgs e) { this.cBMouse.Checked = true; } private void labLinkAbout_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { using (FrmAbout fAbout = new FrmAbout()) { fAbout.ShowDialog(); } } }}
评论