Wow魔兽世界自动登陆器

       前一段时间疯狂的迷上了魔兽世界,为之疯狂,但是9c的5区,让多少玩家郁闷啊,守护之剑每天排队800+,还不停地卡机,掉线,本人上班族,每天晚上6点下班回家排队,上线也都8点多了,MC啊,黑E啊,AQL啊等活动早开始了,十分的郁闷!

     为了按时玩游戏,本着将魔兽进行到底的原则,决定开发一个魔兽的自动登陆器,以解决燃眉之急,哈哈!

     首先定义一个类ViaStruct,用来存储游戏的路径,等待时间,以及用户名,密码!

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Windows.Forms;
using System.Threading;
using System.Diagnostics;
namespace KeyBoardInput
{
    [Serializable]
    public class ViaStruct
    {
        private string timer = "";
        private string filepath = "";
        private string username = "";
        private string pwd = "";
        private string timer2 = "";
        public bool SuccessFlag = false;
        public ViaStruct()
        {
            SuccessFlag=ReadFormKBI();
        }

        #region 属性
        public string Timer
        {
            get { return timer; }
            set { timer = value; }
        }
        public string FilePath
        {
            get { return filepath; }
            set { filepath = value; }
        }
        public string UserName
        {
            get { return username; }
            set { username = value; }
        }
        public string Pwd
        {
            get { return pwd; }
            set { pwd = value; }
        }
        public string Timer2
        {
            get { return timer2; }
            set { timer2 = value; }
        }
        #endregion

        private bool ReadFormKBI()
        {
            StreamReader sr = new StreamReader("info.txt");
            if ((this.filepath = sr.ReadLine()) == null || this.filepath == "")
            {
                return false;
            }
            this.timer = sr.ReadLine();
            this.timer2 = sr.ReadLine();
            this.username = sr.ReadLine();
            this.pwd = sr.ReadLine();
            sr.Close();
            sr.Dispose();
            GC.Collect();
            return true;
        }

        public void WriteToKBI()
        {
            Thread th = new Thread(new ThreadStart(NewMethod));
            th.Start();
        }

        private void NewMethod()
        {
            try
            {
               
                StreamWriter sw = new StreamWriter("info.txt");
                sw.WriteLine(this.filepath);
                sw.Flush();
                sw.WriteLine(this.timer);
                sw.Flush();
                sw.WriteLine(this.timer2);
                sw.Flush();
                sw.WriteLine(this.username);
                sw.Flush();
                sw.WriteLine(this.pwd);
                sw.Flush();
             
                sw.Close();

                MessageBox.Show("写入成功!");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}

 

然后编写Form1窗口

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Threading;


namespace KeyBoardInput
{
   

    public partial class Form1 : Form
    {
        ViaStruct via;
        Thread th;
        Thread ti;
        public Form1()
        {
            InitializeComponent();
            via = new ViaStruct();
        }

      

        private void Form1_Load(object sender, EventArgs e)
        {
            this.textBox1.Text = via.UserName;
            this.textBox2.Text = via.Pwd;
            this.textBox3.Text = via.FilePath;
            this.textBox4.Text = via.Timer2;
            this.comboBox1.Text = via.Timer;
            th = new Thread(new ThreadStart(NewMethod));
            th.Start();
           
          
        }

        private void NewMethod()
        {
            if (via.SuccessFlag)
            {
                try
                {
                    Thread.Sleep(Convert.ToInt32((Convert.ToDecimal(via.Timer) * 60 * 1000)));//开起程序后等待
                                                                                                                                                          //via.Timer时间内启动程序
                    Process.Start(via.FilePath);
                    Thread.Sleep(Convert.ToInt32((Convert.ToDecimal(via.Timer2) * 60 * 1000)));//启动程序后等待                                                                                                                                      //via.Timer2时间输入用户名密码
                }
                catch (Exception ex)
                {
          
                  if(ex.GetType().ToString()!="System.Threading.ThreadAbortException")
                    MessageBox.Show(ex.Message+"1");
                }               
            }
            if (via.SuccessFlag)
            {
                MySendKeys();
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            this.openFileDialog1.RestoreDirectory = true;
            if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                this.textBox3.Text = this.openFileDialog1.FileName;
                      
            }
           // MessageBox.Show(Environment.CurrentDirectory);
           
        }

        private void notifyIcon1_DoubleClick(object sender, EventArgs e)
        {
            this.Show();
        }

        private void Form1_MinimumSizeChanged(object sender, EventArgs e)
        {
            this.Visible = false;
        }

        private void MySendKeys()//输入用户名密码
        {
           
            foreach (char ArrayValue in via.UserName.ToCharArray())
            {
                SendKeys.SendWait(ArrayValue.ToString());
                Thread.Sleep(10);
            }
            SendKeys.SendWait("{Tab}");
            foreach (char ArrayValue in via.Pwd.ToCharArray())
            {
                SendKeys.SendWait(ArrayValue.ToString());
                Thread.Sleep(10);
            }
            SendKeys.SendWait("{Enter}");
          
        }

        private void button2_Click(object sender, EventArgs e)//给Via对象赋值
        {
            via.Timer = this.comboBox1.Text;
            via.Timer2 = this.textBox4.Text;
            via.FilePath = this.textBox3.Text;        
            via.UserName = this.textBox1.Text;
            via.Pwd = this.textBox2.Text;
            via.WriteToKBI();          
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)//关闭窗口后推出线程
        {
            if (th.ThreadState != System.Threading.ThreadState.Aborted)
                th.Abort();
            if (ti!=null&&ti.ThreadState !=System.Threading.ThreadState.Aborted)
                ti.Abort();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            th.Abort();
            ti = new Thread(new ThreadStart(PrograssImmediately));
            ti.Start();
        }

        private void PrograssImmediately()
        {
            if (via.SuccessFlag)
            {
                try
                {
                    Process.Start(via.FilePath);
                    Thread.Sleep(Convert.ToInt32((Convert.ToDecimal(via.Timer2) * 60 * 1000)));
                }
                catch (Exception ex)
                {
                    //MessageBox.Show(ex.GetType().ToString());
                    if (ex.GetType().ToString() != "System.Threading.ThreadAbortException")
                        MessageBox.Show(ex.Message + "1");
                }
            }
            if (via.SuccessFlag)
            {
                MySendKeys();
            }
        }  

    }
}

把改程序的快捷方式拷入启动里,让其成为开机自启动程序

程序在VS2005 WinXp系统下测试成功!

 

局限性:

1.需要主板BIOS支持自动开机;

2.开机以后电脑就连在互连网上;

3.需要.net framework2.0的支持

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
模拟鼠标和键盘 注意:不支持Windows 8 / 8.1。 Interceptor是Windows键盘驱动程序的包装器(包装http://oblita.com/Interception)。 使用驱动程序,Interceptor可以模拟按键和鼠标点击... 使用DirectX的游戏,通常不接受使用SendInput()的击键 Windows的受保护区域,如Windows登录屏幕或UAC调暗屏幕 任何应用程序 因为驱动程序模拟击键和鼠标单击,所以目标窗口必须处于活动状态(即,在发送击键和鼠标点击时,不能在另一个窗口上执行多任务)。 如何使用 下载并构建此项目并在项目中引用其DLL。 下载'interception.dll',这是一个由驱动程序作者编写的独立库。将它放在与可执行文件相同的目录中。这是必需的。 从作者的网页下载并安装“install-interception.exe”。安装后重新启动计算机。 在您的代码中,要加载驱动程序,请调用(阅读下面的代码注释;您必须设置过滤模式以捕获按键事件或发送按键操作!): Input input = new Input(); // Be sure to set your keyboard filter to be able to capture key presses and simulate key presses // KeyboardFilterMode.All captures all events; 'Down' only captures presses for non-special keys; 'Up' only captures releases for non-special keys; 'E0' and 'E1' capture presses/releases for special keys input.KeyboardFilterMode = KeyboardFilterMode.All; // You can set a MouseFilterMode as well, but you don't need to set a MouseFilterMode to simulate mouse clicks // Finally, load the driver input.Load(); 做你的东西。 input.MoveMouseTo(5, 5); // Please note this doesn't use the driver to move the mouse; it uses System.Windows.Forms.Cursor.Position input.MoveMouseBy(25, 25); // Same as above ^ input.SendLeftClick(); input.KeyDelay = 1; // See below for explanation; not necessary in non-game apps input.SendKeys(Keys.Enter); // Presses the ENTER key down and then up (this constitutes a key press) // Or you can do the same thing above using these two lines of code input.SendKeys(Keys.Enter, KeyState.Down); Thread.Sleep(1); // For use in games, be sure to sleep the thread so the game can capture all events. A lagging game cannot process input quickly, and you so you may have to adjust this to as much as 40 millisecond delay. Outside of a game, a delay of even 0 milliseconds can work (instant key presses). input.SendKeys(Keys.Enter, KeyState.Up); input.SendText("hello, I am typing!"); /* All these following characters / numbers / symbols work */ input.SendText("abcdefghijklmnopqrstuvwxyz"); input.SendText("1234567890"); input.SendText("!@#$%^&*()"); input.SendText("[]\\;',./"); input.SendText("{}|:\"?"); // And finally input.Unload(); 笔记: BadImageFormatException如果您没有为解决方案中的所有项目(包括此项目)使用正确的体系结构(x86或x64),则可能会获得。因此,您可能必须下载此项目的源代码才能将其重建为正确的体系结构。这应该很简单,构建过程应该没有错误。 您必须从http://oblita.com/Interception下载'interception.dll' 。 如果你已经完成了以上所有操作(正确安装了拦截驱动程序,将interception.dll放在你的项目文件夹中),你仍然无法发送击键: 驱动程序有一个限制,即它不能在不接收至少一次击键的情况下发送击键。这是因为驱动程序不知道键盘是哪个设备ID,因此它必须等待接收击键以从击键中推断出设备ID。 总之,在发送击键之前,请始终按键盘一次。点按任意键。然后你可以发送击键。这不适用于接收击键,因为通过接收击键,您当然已经按下了一个键。 MoveMouseTo()和MoveMouseBy()完全忽略键盘驱动程序。它使用System.Windows.Forms.Position来设置和获取游标的位置(它为下面的各个函数调用标准的Win32 API)。 原因是,在探索键盘驱动程序的鼠标移动功能时,我注意到它没有按像素单位移动光标,而是似乎通过加速移动光标。当我想将光标移动到某个位置时,这会不断产生不一致的值。因为Win32游标设置API通常不被游戏等阻止,所以我发现只需调用这些标准API即可,而无需使用驱动程序。请注意,这仅适用于设置光标位置。拦截光标仍然可以正常工作。例如,您可以使用Interceptor反转鼠标的x和y轴。
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值