war3显血

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;

using MouseKeyboardLibrary;
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {

        #region DllImport
        [DllImport("User32.dll")]
        public static extern void keybd_event(Byte bVk, Byte bScan, Int32 dwFlags, Int32 dwExtraInfo);
        #endregion

         public Form1()
        {
            InitializeComponent();
        }
        int aa = 1;
        private void Form1_Load(object sender, EventArgs e)
        {
            button1.Text = "帮助";
            this.BackColor = Color.DarkCyan;
            label1.Text = "hook wait";
            KeyboardHook keyboardHook = new KeyboardHook();
            keyboardHook.KeyPress += new KeyPressEventHandler(keyboardHook_KeyPress);
            keyboardHook.Start();
        }
        void keyboardHook_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Escape)
                this.Close();
            if (e.KeyChar == (char)Keys.W)
                df();
        }
        byte a = 219; //键盘上 [ 键的代码。按[可显示友方单位生命值。
        byte b =221;// 键盘上] 键的代码。按]可显示敌方单位生命值。

        public void df() {

            if (aa == 1)
            {

                keybd_event(a, 0, 0, 0);
                keybd_event(b, 0, 0, 0);
                label1.Text = "hook start";


                aa++;
            }
            else
            {

                keybd_event(a, 0, 2, 0);
                keybd_event(b, 0, 2, 0);
                label1.Text = "hook end";

                aa = 1;
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Esc:退出 ;W:显血","魔兽显血辅助->神之df作品");

        }


    }
}

//需要用到MouseKeyboardLibrary这个类文件,感兴趣的可以向我索取:[email protected]
  • 刚毕业那阵子,风靡war3这个游戏,基本陪伴了我整个大学生活,甚至毕业后仍然陪伴了很长时间,直到现在,偶尔还是能看到有人玩这个
  • 那时一直喜爱魔兽争霸,于是自己写了个辅助
  • 是很久以前的事了
  • 那时很少用csdn,其实是因为那时还用不好csdn,所以很多代码都贴在新浪博客里

你可能感兴趣的:(C#)