您的位置:首页 > 编程语言

QQ游戏自动登录器,源代码(仅供参考)

2006-12-12 17:44 597 查看
新的游戏大厅已经Fix了这个BUG

现将代码公布,抛转引玉!


using System;


using System.Drawing;


using System.Collections;


using System.ComponentModel;


using System.Windows.Forms;


using System.Data;


using System.Runtime.InteropServices;


using System.Threading;//Thread;


using System.Management;


//using CustomUIControls;


//using System.Net;


using System.IO;


//using System.Xml;


//using Sloppycode.net;






namespace QQ自动登录器




...{




/**//// <summary>


/// Form1 的摘要说明。


/// </summary>


public class Form1 : System.Windows.Forms.Form




...{




[DllImport("user32.dll")]


static extern bool SetCursorPos(int X, int Y);


//模拟鼠标


private readonly int MOUSEEVENTF_LEFTDOWN = 0x2;


private System.Windows.Forms.TextBox textBox1;


private System.Windows.Forms.Label label1;


private System.Windows.Forms.TextBox textBox2;


private System.Windows.Forms.Label label2;


private System.Windows.Forms.ListBox listBox1;


private System.Windows.Forms.Button button1;


private System.Windows.Forms.TextBox textBox3;


private System.Windows.Forms.Button button2;


private System.Windows.Forms.Label label3;


int NUM=9999;


int N=0;


string MP1="",MP2="";


public string Url="";


private System.Windows.Forms.Label label4;


private System.Windows.Forms.Timer waittimer;


private System.Windows.Forms.Button button3;


private readonly int MOUSEEVENTF_LEFTUP = 0x4;


[DllImport("user32")]


public static extern void mouse_event(int dwFlags, int dx, int dy, int dwData, int dwExtraInfo);


//--------


[DllImport("user32.dll")]


static extern void keybd_event(


byte bVk,


byte bScan,


uint dwFlags,


uint dwExtraInfo


);






private System.Windows.Forms.Button autologinbutton;


private System.ComponentModel.IContainer components;




public Form1()




...{


//


// Windows 窗体设计器支持所必需的


//


InitializeComponent();




//


// TODO: 在 InitializeComponent 调用后添加任何构造函数代码


//


}






/**//// <summary>


/// 清理所有正在使用的资源。


/// </summary>


protected override void Dispose( bool disposing )




...{


if( disposing )




...{


if (components != null)




...{


components.Dispose();


}


}


base.Dispose( disposing );


}






Windows 窗体设计器生成的代码#region Windows 窗体设计器生成的代码




/**//// <summary>


/// 设计器支持所需的方法 - 不要使用代码编辑器修改


/// 此方法的内容。


/// </summary>


private void InitializeComponent()




...{


this.components = new System.ComponentModel.Container();


System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));


this.autologinbutton = new System.Windows.Forms.Button();


this.textBox1 = new System.Windows.Forms.TextBox();


this.label1 = new System.Windows.Forms.Label();


this.textBox2 = new System.Windows.Forms.TextBox();


this.label2 = new System.Windows.Forms.Label();


this.listBox1 = new System.Windows.Forms.ListBox();


this.button1 = new System.Windows.Forms.Button();


this.textBox3 = new System.Windows.Forms.TextBox();


this.button2 = new System.Windows.Forms.Button();


this.label3 = new System.Windows.Forms.Label();


this.label4 = new System.Windows.Forms.Label();


this.waittimer = new System.Windows.Forms.Timer(this.components);


this.button3 = new System.Windows.Forms.Button();


this.SuspendLayout();


//


// autologinbutton


//


this.autologinbutton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));


this.autologinbutton.Location = new System.Drawing.Point(336, 344);


this.autologinbutton.Name = "autologinbutton";


this.autologinbutton.Size = new System.Drawing.Size(96, 24);


this.autologinbutton.TabIndex = 0;


this.autologinbutton.Text = "单个登录";


this.autologinbutton.Click += new System.EventHandler(this.autologinbutton_Click);


//


// textBox1


//


this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)


| System.Windows.Forms.AnchorStyles.Right)));


this.textBox1.Location = new System.Drawing.Point(72, 344);


this.textBox1.Name = "textBox1";


this.textBox1.Size = new System.Drawing.Size(256, 21);


this.textBox1.TabIndex = 1;


this.textBox1.Text = "";


//


// label1


//


this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));


this.label1.Location = new System.Drawing.Point(16, 344);


this.label1.Name = "label1";


this.label1.Size = new System.Drawing.Size(56, 23);


this.label1.TabIndex = 2;


this.label1.Text = "QQ号";


//


// textBox2


//


this.textBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)


| System.Windows.Forms.AnchorStyles.Right)));


this.textBox2.Location = new System.Drawing.Point(72, 376);


this.textBox2.Name = "textBox2";


this.textBox2.Size = new System.Drawing.Size(256, 21);


this.textBox2.TabIndex = 3;


this.textBox2.Text = "";


//


// label2


//


this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));


this.label2.Location = new System.Drawing.Point(16, 376);


this.label2.Name = "label2";


this.label2.Size = new System.Drawing.Size(40, 23);


this.label2.TabIndex = 4;


this.label2.Text = "密码";


//


// listBox1


//


this.listBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)


| System.Windows.Forms.AnchorStyles.Left)


| System.Windows.Forms.AnchorStyles.Right)));


this.listBox1.ItemHeight = 12;


this.listBox1.Location = new System.Drawing.Point(24, 56);


this.listBox1.Name = "listBox1";


this.listBox1.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended;


this.listBox1.Size = new System.Drawing.Size(304, 268);


this.listBox1.TabIndex = 5;


this.listBox1.DoubleClick += new System.EventHandler(this.listBox1_DoubleClick);


//


// button1


//


this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));


this.button1.Location = new System.Drawing.Point(336, 56);


this.button1.Name = "button1";


this.button1.Size = new System.Drawing.Size(96, 40);


this.button1.TabIndex = 6;


this.button1.Text = "读取QQ文件...";


this.button1.Click += new System.EventHandler(this.button1_Click_1);


//


// textBox3


//


this.textBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)


| System.Windows.Forms.AnchorStyles.Right)));


this.textBox3.Location = new System.Drawing.Point(24, 24);


this.textBox3.Name = "textBox3";


this.textBox3.Size = new System.Drawing.Size(304, 21);


this.textBox3.TabIndex = 7;


this.textBox3.Text = "C:/Program Files/Tencent/QQGame/QQGame.exe";


//


// button2


//


this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));


this.button2.Location = new System.Drawing.Point(336, 24);


this.button2.Name = "button2";


this.button2.Size = new System.Drawing.Size(32, 23);


this.button2.TabIndex = 8;


this.button2.Text = "...";


this.button2.Click += new System.EventHandler(this.button2_Click);


//


// label3


//


this.label3.Location = new System.Drawing.Point(8, 8);


this.label3.Name = "label3";


this.label3.Size = new System.Drawing.Size(376, 16);


this.label3.TabIndex = 9;


this.label3.Text = "QQGame文件位置";


//


// label4


//


this.label4.Location = new System.Drawing.Point(336, 104);


this.label4.Name = "label4";


this.label4.Size = new System.Drawing.Size(100, 224);


this.label4.TabIndex = 10;


//


// waittimer


//


this.waittimer.Interval = 6000;


this.waittimer.Tick += new System.EventHandler(this.waittimer_Tick);


//


// button3


//


this.button3.Location = new System.Drawing.Point(336, 376);


this.button3.Name = "button3";


this.button3.Size = new System.Drawing.Size(96, 23);


this.button3.TabIndex = 11;


this.button3.Text = "批量登陆";


this.button3.Click += new System.EventHandler(this.button3_Click);


//


// Form1


//


this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);


this.ClientSize = new System.Drawing.Size(442, 416);


this.Controls.Add(this.button3);


this.Controls.Add(this.label4);


this.Controls.Add(this.label3);


this.Controls.Add(this.button2);


this.Controls.Add(this.textBox3);


this.Controls.Add(this.button1);


this.Controls.Add(this.listBox1);


this.Controls.Add(this.label2);


this.Controls.Add(this.textBox2);


this.Controls.Add(this.label1);


this.Controls.Add(this.textBox1);


this.Controls.Add(this.autologinbutton);


this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));


this.Name = "Form1";


this.Text = "QQ游戏自动登录器 V4.0 蚊子特别版 by NOIR";


this.Load += new System.EventHandler(this.Form1_Load);


this.ResumeLayout(false);




}


#endregion






/**//// <summary>


/// 应用程序的主入口点。


/// </summary>


[STAThread]


static void Main()




...{


Application.Run(new Form1());


}


void process()




...{


//Application.


System.Diagnostics.Process Proc ;


System.Diagnostics.ProcessStartInfo Info = new System.Diagnostics.ProcessStartInfo();


Info.FileName=@Url;


Proc = System.Diagnostics.Process.Start(Info);






int X=500,Y=341;


SetCursorPos(X,Y);


mouse_event(MOUSEEVENTF_LEFTDOWN , 0 , 0 , 0, 0);


mouse_event(MOUSEEVENTF_LEFTUP, 0 , 0 , 0, 0);


//SendKeys.Send("{A}");




//mouse_event(MOUSEEVENTF_LEFTUP, X * 65536 / 1024, Y * 65536 / 768, 0, 0);


//mouse_event(MOUSEEVENTF_RightDown, X * 65536 / 1024, Y * 65536 / 768, 0, 0);


//mouse_event(MOUSEEVENTF_RightUp, X * 65536 / 1024, Y * 65536 / 768, 0, 0);








//mouse_event(MOUSEEVENTF_LEFTDOWN, X, Y, 0, 0);


//mouse_event(MOUSEEVENTF_LEFTUP, X, Y, 0, 0);


//其中X,Y分别是你要点击的点的横坐标和纵坐标




}




public void newthread(string uname,string password)




...{






}


private void autologinbutton_Click(object sender, System.EventArgs e)




...{


//process();






//Thread thread = new Thread(new ThreadStart(processnew));


//thread.Start();


processnew();




}


void processnew()




...{//读取QQ号和密码


//自动打开游戏大厅


System.Diagnostics.Process Proc;


System.Diagnostics.ProcessStartInfo Info = new System.Diagnostics.ProcessStartInfo();


Info.FileName=textBox3.Text;


Proc = System.Diagnostics.Process.Start(Info);






Proc.WaitForInputIdle();


//---------------------


int X=457,Y=390;


SetCursorPos(X,Y);




mouse_event(MOUSEEVENTF_LEFTDOWN , 0 , 0 , 0, 0);


mouse_event(MOUSEEVENTF_LEFTUP, 0 , 0 , 0, 0);






//Proc.WaitForInputIdle();


//--------------------


string txt1=textBox1.Text;


for(int i=0;i<textBox1.Text.Length;i++)




...{


string a=txt1.Substring(i,1);


a="{"+a+"}";


//MessageBox.Show(a);


SendKeys.Send(a);






}




Proc.WaitForInputIdle();


SendKeys.Send("{TAB}");


//X=463;Y=419;


//SetCursorPos(X,Y);


//mouse_event(MOUSEEVENTF_LEFTDOWN , 0 , 0 , 0, 0);


//mouse_event(MOUSEEVENTF_LEFTUP, 0 , 0 , 0, 0);










string txt2=textBox2.Text;




for(int i=0;i<textBox2.Text.Length;i++)




...{


string a=txt2.Substring(i,1);


a="{"+a+"}";


SendKeys.Send(a);






}
















//for(int k=1;k<=11;k++)


//{


//SendKeys.Send("{TAB}");


//}


SendKeys.Send("{Enter}");


//Proc.CloseMainWindow();


SendKeys.Send("%{Tab}");


//SendKeys.Send("{N}");












//Proc.WaitForInputIdle();


//X=969;Y=8;


//SetCursorPos(X,Y);


//mouse_event(MOUSEEVENTF_LEFTDOWN , 0 , 0 , 0, 0);


//mouse_event(MOUSEEVENTF_LEFTUP, 0 , 0 , 0, 0);




//mouse_event(MOUSEEVENTF_LEFTDOWN , 0 , 0 , 0, 0);


//mouse_event(MOUSEEVENTF_LEFTUP, 0 , 0 , 0, 0);








waittimer.Start();


//MessageBox.Show("chulai");




















}






void getCUPinfo()




...{


string cpuInfo = "";//cpu序列号


ManagementClass cimobject = new


ManagementClass("Win32_Processor");


ManagementObjectCollection moc = cimobject.GetInstances();


foreach(ManagementObject mo in moc)




...{


cpuInfo = mo.Properties["ProcessorId"].Value.ToString();


MessageBox.Show(cpuInfo);


}


}


private void Form1_Load(object sender, System.EventArgs e)




...{




label4.Text="使用我的方法:先指定QQGame.exe的存放路径,然后选取你的密码文件,双击密码文件即可自动登录,如果有登陆不成功的地方,可能由于网络问题,请多试几次!我的主人是NOIR";


info dlg = new info();//对话框


dlg.ShowDialog();




//int NUM=dlg.label3.Text


//MessageBox.Show(dlg.label3.Text);


string Snum=dlg.label3.Text;


if(Snum=="")




...{




}


else




...{


NUM=5;


label3.Text+=" 试用版本";








}








//process();


//getCUPinfo();


//this.Cursor = Cursors.WaitCursor;


//Thread thread = new Thread(new ThreadStart(Loadtxt));


//thread.Start();


//this.Cursor = Cursors.Default;




}




private void listBox1_DoubleClick(object sender, System.EventArgs e)




...{


//int count=listBox1.SelectedItems.Count;




//for(int y=0;y<2;y++)


//{
















string MP=listBox1.SelectedItem.ToString().Trim();


int i=0,j=0,flag=0;


i=MP.IndexOf("----",i);//i=Code.IndexOf("<font color="red">",i);






//textBox1.Text=MP.Substring(0,i);






//textBox2.Text=MP.Substring(i+4,MP.Length-i-4);








j=MP.IndexOf("----",i+4);


//MessageBox.Show(j.ToString());


if(j==-1)




...{


flag=1;


}


else




...{


flag=2;


}










if(flag==1)




...{


textBox1.Text=MP.Substring(0,i);






textBox2.Text=MP.Substring(i+4,MP.Length-i-4);




/**////MessageBox.Show("flag==1");




//processnew();


}


else if(flag==2)




...{


textBox1.Text=MP.Substring(0,i);






textBox2.Text=MP.Substring(i+4,j-i-4);


//MessageBox.Show("flag==2");


//processnew();




}






int po=listBox1.SelectedIndex;


string sss=listBox1.SelectedItem.ToString()+"----*";//listBox1.SelectedIndex


listBox1.Items.RemoveAt(po);


listBox1.Items.Insert(po,sss);




processnew();








//waittimer.Start();


//waittimer.Stop();




//}




}




private void button1_Click(object sender, System.EventArgs e)




...{


int X=457,Y=390;


SetCursorPos(X,Y);




mouse_event(MOUSEEVENTF_LEFTDOWN , 0 , 0 , 0, 0);


mouse_event(MOUSEEVENTF_LEFTUP, 0 , 0 , 0, 0);


mouse_event(MOUSEEVENTF_LEFTDOWN , 0 , 0 , 0, 0);


mouse_event(MOUSEEVENTF_LEFTUP, 0 , 0 , 0, 0);


SendKeys.Send("{1}");






}




private void button1_Click_1(object sender, System.EventArgs e)




...{


listBox1.Items.Clear();




if(textBox3.Text.Length==0)




...{


MessageBox.Show("请确定QQGame.exe的路径!");


}


OpenFileDialog openFileDialog = new OpenFileDialog();




openFileDialog.Filter = " 文本文件(*.txt)|*.txt| 所有合适文件(*.txt)|*.txt";


if(DialogResult.OK == openFileDialog.ShowDialog())






...{


//MessageBox.Show(openFileDialog.FileName);


string sname=openFileDialog.FileName;


StreamReader objReader = new StreamReader(sname);


string sLine="";


//ArrayList arrText = new ArrayList();




//int count=0;


//int num=0;


//string QQ="";




sLine = objReader.ReadLine();


while (sLine != null&&NUM!=0)




...{


listBox1.Items.Add(sLine);


sLine = objReader.ReadLine();


NUM--;


}






}


}




private void button2_Click(object sender, System.EventArgs e)




...{


OpenFileDialog openFileDialog = new OpenFileDialog();




openFileDialog.Filter = " QQgame(QQgame.exe)| QQgame.exe";


if(DialogResult.OK == openFileDialog.ShowDialog())




...{


Url=openFileDialog.FileName;


textBox3.Text=openFileDialog.FileName;


}




}




private void listBox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)




...{


//鼠标按下时




string MP=listBox1.SelectedItem.ToString().Trim();


int i=0,j=0,flag=0;


i=MP.IndexOf("----",i);//i=Code.IndexOf("<font color="red">",i);






//textBox1.Text=MP.Substring(0,i);






//textBox2.Text=MP.Substring(i+4,MP.Length-i-4);








j=MP.IndexOf("----",i+4);


//MessageBox.Show(j.ToString());


if(j==-1)




...{


flag=1;


}


else




...{


flag=2;


}










if(flag==1)




...{


textBox1.Text=MP.Substring(0,i);






textBox2.Text=MP.Substring(i+4,MP.Length-i-4);




/**////MessageBox.Show("flag==1");




}


else if(flag==2)




...{


textBox1.Text=MP.Substring(0,i);






textBox2.Text=MP.Substring(i+4,j-i-4);


//MessageBox.Show("flag==2");






}


}




private void button3_Click(object sender, System.EventArgs e)




...{


//批量登陆


N=listBox1.SelectedItems.Count;//取选了多少数


waittimer.Start();


}




private void waittimer_Tick(object sender, System.EventArgs e)




...{






//for(int ii=0;ii<N;i++)


//{


N--;


if(N<0)




...{


waittimer.Stop();


return;


}


MP1=listBox1.SelectedItems
.ToString().Trim();


int i=0,j=0,flag=0;


i=MP1.IndexOf("----",i);


j=MP1.IndexOf("----",i+4);


if(j==-1)




...{


flag=1;


}


else




...{


flag=2;


}


if(flag==1)




...{


textBox1.Text=MP1.Substring(0,i);






textBox2.Text=MP1.Substring(i+4,MP1.Length-i-4);




}


else if(flag==2)




...{


textBox1.Text=MP1.Substring(0,i);






textBox2.Text=MP1.Substring(i+4,j-i-4);










}






processnew();


}




}


}

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: