C#实现QQ客户端自动登录1

using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;

namespace QQ2010AutoLogin
{
publicclass WindowsAPI
{
[DllImport(
"user32.dll")]
privatestaticextern UInt32 SendInput(UInt32 nInputs, ref INPUT pInputs, int cbSize);

[DllImport(
"user32.dll")]
privatestaticextern UInt32 SendInput(UInt32 nInputs, INPUT[] pInputs, int cbSize);

[DllImport(
"user32.dll", EntryPoint ="GetMessageExtraInfo", SetLastError =true)]
privatestaticextern IntPtr GetMessageExtraInfo();

[DllImport(
"user32.dll")]
privatestaticexternbool SetCursorPos(int X, int Y);//设置鼠标位置

publicenum InputType
{
INPUT_MOUSE
=0,
INPUT_KEYBOARD
=1,
INPUT_HARDWARE
=2,
}

[Flags()]
publicenum MOUSEEVENTF
{
MOVE
=0x0001, //mouse move
LEFTDOWN =0x0002, //left button down
LEFTUP =0x0004, //left button up
RIGHTDOWN =0x0008, //right button down
RIGHTUP =0x0010, //right button up
MIDDLEDOWN =0x0020, //middle button down
MIDDLEUP =0x0040, //middle button up
XDOWN =0x0080, //x button down
XUP =0x0100, //x button down
WHEEL =0x0800, //wheel button rolled
VIRTUALDESK =0x4000, //map to entire virtual desktop
ABSOLUTE =0x8000, //absolute move
}

[Flags()]
publicenum KEYEVENTF
{
EXTENDEDKEY
=0x0001,
KEYUP
=0x0002,
UNICODE
=0x0004,
SCANCODE
=0x0008,
}

[StructLayout(LayoutKind.Explicit)]
privatestruct INPUT
{
[FieldOffset(
0)]
public Int32 type;//0-MOUSEINPUT;1-KEYBDINPUT;2-HARDWAREINPUT
[FieldOffset(4)]
public KEYBDINPUT ki;
[FieldOffset(
4)]
public MOUSEINPUT mi;
[FieldOffset(
4)]
public HARDWAREINPUT hi;
}

[StructLayout(LayoutKind.Sequential)]
privatestruct MOUSEINPUT
{
public Int32 dx;
public Int32 dy;
public Int32 mouseData;
public Int32 dwFlags;
public Int32 time;
public IntPtr dwExtraInfo;
}

[StructLayout(LayoutKind.Sequential)]
privatestruct KEYBDINPUT
{
public Int16 wVk;
public Int16 wScan;
public Int32 dwFlags;
public Int32 time;
public IntPtr dwExtraInfo;
}

[StructLayout(LayoutKind.Sequential)]
privatestruct HARDWAREINPUT
{
public Int32 uMsg;
public Int16 wParamL;
public Int16 wParamH;
}

///<summary>
/// 模拟鼠标左键点击
///</summary>
publicstaticvoid SendMouseClick()
{
INPUT input_down
=new INPUT();
input_down.mi.dx
=0;
input_down.mi.dy
=0;
input_down.mi.mouseData
=0;
input_down.mi.dwFlags
= (int)MOUSEEVENTF.LEFTDOWN;
SendInput(
1, ref input_down, Marshal.SizeOf(input_down));

INPUT input_up
= input_down;
input_up.mi.dwFlags
= (int)MOUSEEVENTF.LEFTUP;
SendInput(
1, ref input_up, Marshal.SizeOf(input_up));
}

///<summary>
/// 在x,y位置模拟鼠标点击
///</summary>
///<param name="dwFlagsDown">MOUSEEVENTF</param>
///<param name="dwFlagsUp">MOUSEEVENTF</param>
///<param name="x">点击的x坐标</param>
///<param name="y">点击的y坐标</param>
publicstaticvoid SendMouseLeftClick(int dwFlagsDown, int dwFlagsUp, int x, int y)
{
INPUT[] input
=new INPUT[2];
MOUSEINPUT mouseinput_down
=new MOUSEINPUT();
MOUSEINPUT mouseinput_up
=new MOUSEINPUT();

mouseinput_down.dwFlags
= dwFlagsDown;
mouseinput_up.dwFlags
= dwFlagsUp;
input[
0].type = (int)InputType.INPUT_MOUSE;
input[
0].mi = mouseinput_down;
input[
1].type = (int)InputType.INPUT_MOUSE;
input[
1].mi = mouseinput_up;
SetCursorPos(x, y);
SendInput(
1, input, Marshal.SizeOf(input[0]));//down
SendInput(1, input, Marshal.SizeOf(input[1]));//up
}

///<summary>
/// 发送单一按键,如Tab,Shift,Home,End
///</summary>
///<param name="wVk">VK_TAB,VK_SHIFT</param>
publicstaticvoid SendSingleKey(int wVk)
{
INPUT input_down
=new INPUT();
input_down.type
= (int)InputType.INPUT_KEYBOARD;
input_down.ki.dwFlags
=0;
input_down.ki.wVk
= (short)wVk;
SendInput(
1, ref input_down, Marshal.SizeOf(input_down));//keydown

INPUT input_up
=new INPUT();
input_up.type
= (int)InputType.INPUT_KEYBOARD;
input_up.ki.wVk
= (short)wVk;
input_up.ki.dwFlags
= (int)KEYEVENTF.KEYUP;
SendInput(
1, ref input_up, Marshal.SizeOf(input_up));//keyup
}

///<summary>
/// 发送组合键
///</summary>
///<param name="wVk">VK_SHIFT,VK_TAB;如Shift+A,SendNoUnicodeByParam(VK_SHIFT,Keys.A)</param>
publicstaticvoid SendKeyCombination(int wVk, Keys key)
{
INPUT[] inDown
=new INPUT[4];
inDown[
0] =new INPUT();
inDown[
1] =new INPUT();
inDown[
2] =new INPUT();
inDown[
3] =new INPUT();
inDown[
0].type = inDown[1].type = inDown[2].type = inDown[3].type = (int)InputType.INPUT_KEYBOARD;
inDown[
0].ki.wVk = inDown[2].ki.wVk = (short)wVk;
inDown[
1].ki.wVk = inDown[3].ki.wVk = (short)key;
inDown[
0].ki.dwFlags = inDown[1].ki.dwFlags =0;
inDown[
2].ki.dwFlags = inDown[3].ki.dwFlags = (int)KEYEVENTF.KEYUP;
SendInput(
1, ref inDown[0], Marshal.SizeOf(inDown[0]));//down
SendInput(1, ref inDown[1], Marshal.SizeOf(inDown[1]));//char down
SendInput(1, ref inDown[2], Marshal.SizeOf(inDown[2]));//up
SendInput(1, ref inDown[3], Marshal.SizeOf(inDown[3]));//char up
}

///<summary>
/// 发送Del键
///</summary>
///<param name="count">发送Del键个数</param>
publicstaticvoid SendDelCode(int count)
{
if (count >0)
{
for (int i =0; i < count; i++)
{
INPUT clear_down
=new INPUT();
clear_down.type
= (int)InputType.INPUT_KEYBOARD;
clear_down.ki.dwFlags
=0;
clear_down.ki.wVk
= VK_BACK;
SendInput(
1, ref clear_down, Marshal.SizeOf(clear_down));//down
INPUT clear_up =new INPUT();
clear_up.type
= (int)InputType.INPUT_KEYBOARD;
clear_up.ki.wVk
= VK_BACK;
clear_up.ki.dwFlags
= (int)KEYEVENTF.KEYUP;
SendInput(
1, ref clear_up, Marshal.SizeOf(clear_up));//keyup
}
}
}

///<summary>
/// 发送unicode字符,可发送任意字符(包括汉字),但不能作用于qq上
///</summary>
///<param name="message">发送的字符串</param>
publicstaticvoid SendUnicode(string message)
{
for (int i =0; i < message.Length; i++)
{
INPUT input_down
=new INPUT();
input_down.type
= (int)InputType.INPUT_KEYBOARD;
input_down.ki.dwFlags
= (int)KEYEVENTF.UNICODE;
input_down.ki.wScan
= (short)message[i];
SendInput(
1, ref input_down, Marshal.SizeOf(input_down));//keydown

INPUT input_up
=new INPUT();
input_up.type
= (int)InputType.INPUT_KEYBOARD;
input_up.ki.wScan
= (short)message[i];
input_up.ki.dwFlags
= (int)(KEYEVENTF.KEYUP | KEYEVENTF.UNICODE);
SendInput(
1, ref input_up, Marshal.SizeOf(input_up));//keyup
}
}

///<summary>
/// 发送非unicode字符
///</summary>
///<param name="message">发送的字符串</param>
publicstaticvoid SendNoUnicode(string message)
{
string lower ="abcdefghijklmnopqrstuvwxyz+-*/. []\\;',.`";//密码是小写字母和+ - * / .[]\\;',.`和空格
string upper ="ABCDEFGHIJKLMNOPQRSTUVWXYZ";//密码是大写字母
string other ="~!@#$%^&()_{}|:\"<>?=";

for (int i =0; i < message.Length; i++)
{
short sendChar =0;

if (other.IndexOf(message[i].ToString()) >-1)
{
sendChar
= (short)getKeysByChar2(message[i]);
INPUT[] inDown
=new INPUT[4];
inDown[
0] =new INPUT();
inDown[
1] =new INPUT();
inDown[
2] =new INPUT();
inDown[
3] =new INPUT();
inDown[
0].type = inDown[1].type = inDown[2].type = inDown[3].type = (int)InputType.INPUT_KEYBOARD;
inDown[
0].ki.wVk = inDown[2].ki.wVk = (int)VK_SHIFT;
inDown[
1].ki.wVk = inDown[3].ki.wVk = sendChar;
inDown[
0].ki.dwFlags = inDown[1].ki.dwFlags =0;
inDown[
2].ki.dwFlags = inDown[3].ki.dwFlags = (int)KEYEVENTF.KEYUP;
SendInput(
1, ref inDown[0], Marshal.SizeOf(inDown[0]));//shift down
SendInput(1, ref inDown[1], Marshal.SizeOf(inDown[1]));//char down
SendInput(1, ref inDown[2], Marshal.SizeOf(inDown[2]));//shift up
SendInput(1, ref inDown[3], Marshal.SizeOf(inDown[3]));//char up
continue;
}
elseif (upper.IndexOf(message[i].ToString()) >-1)//如果是大写字母,和Shift一起发送
{
sendChar
= (short)getKeysByChar(message[i]);
//INPUT[] inDown = new INPUT[4];
//inDown[0] = new INPUT();
//inDown[1] = new INPUT();
//inDown[2] = new INPUT();
//inDown[3] = new INPUT();
//inDown[0].type = inDown[1].type = inDown[2].type = inDown[3].type = (int)InputType.INPUT_KEYBOARD;
//inDown[0].ki.wVk = inDown[2].ki.wVk = (int)VK_SHIFT;
//inDown[1].ki.wVk = inDown[3].ki.wVk = sendChar;
//inDown[2].ki.dwFlags = inDown[3].ki.dwFlags = (int)KEYEVENTF.KEYUP;
//SendInput(4, inDown, Marshal.SizeOf(inDown[0]));
//上面发送组合键不能作用于QQ,QQ必须一个一个的发送
INPUT[] inDown =new INPUT[4];
inDown[
0] =new INPUT();
inDown[
1] =new INPUT();
inDown[
2] =new INPUT();
inDown[
3] =new INPUT();
inDown[
0].type = inDown[1].type = inDown[2].type = inDown[3].type = (int)InputType.INPUT_KEYBOARD;
inDown[
0].ki.wVk = inDown[2].ki.wVk = (int)VK_SHIFT;
inDown[
1].ki.wVk = inDown[3].ki.wVk = sendChar;
inDown[
0].ki.dwFlags = inDown[1].ki.dwFlags =0;
inDown[
2].ki.dwFlags = inDown[3].ki.dwFlags = (int)KEYEVENTF.KEYUP;
SendInput(
1, ref inDown[0], Marshal.SizeOf(inDown[0]));//shift down
SendInput(1, ref inDown[1], Marshal.SizeOf(inDown[1]));//char down
SendInput(1, ref inDown[2], Marshal.SizeOf(inDown[2]));//shift up
SendInput(1, ref inDown[3], Marshal.SizeOf(inDown[3]));//char up
continue;
}
elseif (lower.IndexOf(message[i].ToString()) >-1)//小写字母
{
sendChar
= (short)getKeysByChar(message[i]);
}
else
{
sendChar
= (short)message[i];//数字
}

INPUT input_down
=new INPUT();
input_down.type
= (int)InputType.INPUT_KEYBOARD;
input_down.ki.dwFlags
=0;
input_down.ki.wVk
= sendChar;
SendInput(
1, ref input_down, Marshal.SizeOf(input_down));//keydown

INPUT input_up
=new INPUT();
input_up.type
= (int)InputType.INPUT_KEYBOARD;
input_up.ki.wVk
= sendChar;
input_up.ki.dwFlags
= (int)KEYEVENTF.KEYUP;
SendInput(
1, ref input_up, Marshal.SizeOf(input_up));//keyup
}
}

privatestatic Keys getKeysByChar(char c)
{
string str ="abcdefghijklmnopqrstuvwxyz+-*/. []\\;',.`";
int index = str.IndexOf(c.ToString().ToLower());
switch (index)
{
case0:
return Keys.A;
case1:
return Keys.B;
case2:
return Keys.C;
case3:
return Keys.D;
case4:
return Keys.E;
case5:
return Keys.F;
case6:
return Keys.G;
case7:
return Keys.H;
case8:
return Keys.I;
case9:
return Keys.J;
case10:
return Keys.K;
case11:
return Keys.L;
case12:
return Keys.M;
case13:
return Keys.N;
case14:
return Keys.O;
case15:
return Keys.P;
case16:
return Keys.Q;
case17:
return Keys.R;
case18:
return Keys.S;
case19:
return Keys.T;
case20:
return Keys.U;
case21:
return Keys.V;
case22:
return Keys.W;
case23:
return Keys.X;
case24:
return Keys.Y;
case25:
return Keys.Z;
case26:
return Keys.Add;
case27:
return Keys.Subtract;
case28:
return Keys.Multiply;
case29:
return Keys.Divide;
case30:
return Keys.Decimal;
case31:
return Keys.Space;
case32:
return Keys.Oem4;//[]\\;',.
case33:
return Keys.Oem6;
case34:
return Keys.Oem5;
case35:
return Keys.Oem1;
case36:
return Keys.Oem7;
case37:
return Keys.Oemcomma;
case38:
return Keys.Oemtilde;
default:
return Keys.None;
}
}

publicstatic Keys getKeysByChar2(char c)
{
string str ="~!@#$%^&()_{}|:\"<>?=";
int index = str.IndexOf(c.ToString().ToLower());
switch (index)
{
case0:
return Keys.Oemtilde;//~
case1:
return Keys.D1;//!
case2:
return Keys.D2;//@
case3:
return Keys.D3;//#
case4:
return Keys.D4;//$
case5:
return Keys.D5;//%
case6:
return Keys.D6;//^
case7:
return Keys.D7;//&
case8:
return Keys.D9;//(
case9:
return Keys.D0;//)
case10:
return Keys.OemMinus;//_
case11:
return Keys.Oem4;//{
case12:
return Keys.Oem6;//}
case13:
return Keys.Oem5;//|
case14:
return Keys.Oem1;//:
case15:
return Keys.Oem7;//"
case16:
return Keys.Oemcomma;//<
case17:
return Keys.OemPeriod;//>
case18:
return Keys.OemQuestion;//?
case19:
return Keys.Oemplus;//=
default:
return Keys.None;
}
}

//Windows 使用的256个虚拟键码
publicconstint VK_LBUTTON =0x1;
publicconstint VK_RBUTTON =0x2;
publicconstint VK_CANCEL =0x3;
publicconstint VK_MBUTTON =0x4;
publicconstint VK_BACK =0x8;
publicconstint VK_TAB =0x9;
publicconstint VK_CLEAR =0xC;
publicconstint VK_RETURN =0xD;
publicconstint VK_SHIFT =0x10;
publicconstint VK_CONTROL =0x11;
publicconstint VK_MENU =0x12;
publicconstint VK_PAUSE =0x13;
publicconstint VK_CAPITAL =0x14;
publicconstint VK_ESCAPE =0x1B;
publicconstint VK_SPACE =0x20;
publicconstint VK_PRIOR =0x21;
publicconstint VK_NEXT =0x22;
publicconstint VK_END =0x23;
publicconstint VK_HOME =0x24;
publicconstint VK_LEFT =0x25;
publicconstint VK_UP =0x26;
publicconstint VK_RIGHT =0x27;
publicconstint VK_DOWN =0x28;
publicconstint VK_Select =0x29;
publicconstint VK_PRINT =0x2A;
publicconstint VK_EXECUTE =0x2B;
publicconstint VK_SNAPSHOT =0x2C;
publicconstint VK_Insert =0x2D;
publicconstint VK_Delete =0x2E;
publicconstint VK_HELP =0x2F;
publicconstint VK_0 =0x30;
publicconstint VK_1 =0x31;
publicconstint VK_2 =0x32;
publicconstint VK_3 =0x33;
publicconstint VK_4 =0x34;
publicconstint VK_5 =0x35;
publicconstint VK_6 =0x36;
publicconstint VK_7 =0x37;
publicconstint VK_8 =0x38;
publicconstint VK_9 =0x39;
publicconstint VK_A =0x41;
publicconstint VK_B =0x42;
publicconstint VK_C =0x43;
publicconstint VK_D =0x44;
publicconstint VK_E =0x45;
publicconstint VK_F =0x46;
publicconstint VK_G =0x47;
publicconstint VK_H =0x48;
publicconstint VK_I =0x49;
publicconstint VK_J =0x4A;
publicconstint VK_K =0x4B;
publicconstint VK_L =0x4C;
publicconstint VK_M =0x4D;
publicconstint VK_N =0x4E;
publicconstint VK_O =0x4F;
publicconstint VK_P =0x50;
publicconstint VK_Q =0x51;
publicconstint VK_R =0x52;
publicconstint VK_S =0x53;
publicconstint VK_T =0x54;
publicconstint VK_U =0x55;
publicconstint VK_V =0x56;
publicconstint VK_W =0x57;
publicconstint VK_X =0x58;
publicconstint VK_Y =0x59;
publicconstint VK_Z =0x5A;
publicconstint VK_STARTKEY =0x5B;
publicconstint VK_CONTEXTKEY =0x5D;
publicconstint VK_NUMPAD0 =0x60;
publicconstint VK_NUMPAD1 =0x61;
publicconstint VK_NUMPAD2 =0x62;
publicconstint VK_NUMPAD3 =0x63;
publicconstint VK_NUMPAD4 =0x64;
publicconstint VK_NUMPAD5 =0x65;
publicconstint VK_NUMPAD6 =0x66;
publicconstint VK_NUMPAD7 =0x67;
publicconstint VK_NUMPAD8 =0x68;
publicconstint VK_NUMPAD9 =0x69;
publicconstint VK_MULTIPLY =0x6A;
publicconstint VK_ADD =0x6B;
publicconstint VK_SEPARATOR =0x6C;
publicconstint VK_SUBTRACT =0x6D;
publicconstint VK_DECIMAL =0x6E;
publicconstint VK_DIVIDE =0x6F;
publicconstint VK_F1 =0x70;
publicconstint VK_F2 =0x71;
publicconstint VK_F3 =0x72;
publicconstint VK_F4 =0x73;
publicconstint VK_F5 =0x74;
publicconstint VK_F6 =0x75;
publicconstint VK_F7 =0x76;
publicconstint VK_F8 =0x77;
publicconstint VK_F9 =0x78;
publicconstint VK_F10 =0x79;
publicconstint VK_F11 =0x7A;
publicconstint VK_F12 =0x7B;
publicconstint VK_F13 =0x7C;
publicconstint VK_F14 =0x7D;
publicconstint VK_F15 =0x7E;
publicconstint VK_F16 =0x7F;
publicconstint VK_F17 =0x80;
publicconstint VK_F18 =0x81;
publicconstint VK_F19 =0x82;
publicconstint VK_F20 =0x83;
publicconstint VK_F21 =0x84;
publicconstint VK_F22 =0x85;
publicconstint VK_F23 =0x86;
publicconstint VK_F24 =0x87;
publicconstint VK_NUMLOCK =0x90;
publicconstint VK_OEM_SCROLL =0x91;
publicconstint VK_OEM_1 =0xBA;
publicconstint VK_OEM_PLUS =0xBB;
publicconstint VK_OEM_COMMA =0xBC;
publicconstint VK_OEM_MINUS =0xBD;
publicconstint VK_OEM_PERIOD =0xBE;
publicconstint VK_OEM_2 =0xBF;
publicconstint VK_OEM_3 =0xC0;
publicconstint VK_OEM_4 =0xDB;
publicconstint VK_OEM_5 =0xDC;
publicconstint VK_OEM_6 =0xDD;
publicconstint VK_OEM_7 =0xDE;
publicconstint VK_OEM_8 =0xDF;
publicconstint VK_ICO_F17 =0xE0;
publicconstint VK_ICO_F18 =0xE1;
publicconstint VK_OEM102 =0xE2;
publicconstint VK_ICO_HELP =0xE3;
publicconstint VK_ICO_00 =0xE4;
publicconstint VK_ICO_CLEAR =0xE6;
publicconstint VK_OEM_RESET =0xE9;
publicconstint VK_OEM_JUMP =0xEA;
publicconstint VK_OEM_PA1 =0xEB;
publicconstint VK_OEM_PA2 =0xEC;
publicconstint VK_OEM_PA3 =0xED;
publicconstint VK_OEM_WSCTRL =0xEE;
publicconstint VK_OEM_CUSEL =0xEF;
publicconstint VK_OEM_ATTN =0xF0;
publicconstint VK_OEM_FINNISH =0xF1;
publicconstint VK_OEM_COPY =0xF2;
publicconstint VK_OEM_AUTO =0xF3;
publicconstint VK_OEM_ENLW =0xF4;
publicconstint VK_OEM_BACKTAB =0xF5;
publicconstint VK_ATTN =0xF6;
publicconstint VK_CRSEL =0xF7;
publicconstint VK_EXSEL =0xF8;
publicconstint VK_EREOF =0xF9;
publicconstint VK_PLAY =0xFA;
publicconstint VK_ZOOM =0xFB;
publicconstint VK_NONAME =0xFC;
publicconstint VK_PA1 =0xFD;
publicconstint VK_OEM_CLEAR =0xFE;

}
}

  

主程序后台代码

publicpartialclass frmQQ2010AutoLogin : Form
{
KeyboardHook keyboardHook
=new KeyboardHook();//全局按键

public frmQQ2010AutoLogin()
{
InitializeComponent();
}

privatevoid Form1_Load(object sender, EventArgs e)
{
keyboardHook.KeyDown
+=new KeyEventHandler(keyboardHook_KeyDown);
keyboardHook.Start();
}

privatebool validate()
{
if (string.IsNullOrEmpty(txtQQNumber.Text) ||string.IsNullOrEmpty(txtQQPasswd.Text))
{
returnfalse;
}
returntrue;
}

privatevoid btnLogin_Click(object sender, EventArgs e)
{
bool isPass = validate();
if (isPass)
{
//FileVersionInfo version = FileVersionInfo.GetVersionInfo(@"D:\Program Files\Tencent\QQ2010\Bin\QQ.exe");//获取文件版本号
//MessageBox.Show(version.ProductVersion);
QQ2010AutoLogin2.AutoLogin(txtQQNumber.Text.Trim(), txtQQPasswd.Text.Trim());
//QQ2010AutoLogin.QQAutoLogin(txtQQNumber.Text.Trim(), txtQQPasswd.Text.Trim());
//QQ2009AutoLogin.AutoLogin(txtQQNumber.Text.Trim(), txtQQPasswd.Text.Trim());
//QQ2008AutoLogin.AutoLogin(txtQQNumber.Text.Trim(), txtQQPasswd.Text.Trim());
}
else
{
MessageBox.Show(
"QQ号码和密码为必填项!");
txtQQNumber.Focus();
}
}

//全局按键
void keyboardHook_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.F2)
{
bool isPass = validate();
if (isPass)
{
QQ2010AutoLogin2.AutoLogin(txtQQNumber.Text.Trim(), txtQQPasswd.Text.Trim());
//QQ2010AutoLogin.AutoLogin(txtQQNumber.Text.Trim(), txtQQPasswd.Text.Trim());
//QQ2009AutoLogin.AutoLogin(txtQQNumber.Text.Trim(), txtQQPasswd.Text.Trim());
//QQ2008AutoLogin.AutoLogin(txtQQNumber.Text.Trim(), txtQQPasswd.Text.Trim());
}
else
{
MessageBox.Show(
"号码和密码为必填项!");
txtQQNumber.Focus();
}

//获取qq2010账号和密码,密码待研究
// QQ2010Test.GetQQPassword();

//qq游戏自动登录
//IntPtr qqGameMainHwnd = FindWindow("QufPanelWnd", "QQ游戏");
//Thread.Sleep(500);
//if (qqGameMainHwnd != IntPtr.Zero)
//{
// SetForegroundWindow(qqGameMainHwnd);
// Thread.Sleep(200);
// IntPtr qqGameUserHwnd = FindWindowEx(qqGameMainHwnd, IntPtr.Zero, "ComboBox", "");//获取账号框句柄
// SendMessage(qqGameUserHwnd, WM_SETFOCUS, 0, 0);//设置焦点到文本框中

// WindowsAPI.SendUnicode("Y597449899");//测试发送Unicode
////Thread.Sleep(200);
////SendMessage(qqGameUserHwnd, WM_KEYDOWN, VK_TAB, 0);//发送tab
////SendMessage(qqGameUserHwnd, WM_KEYUP, VK_TAB, 0);//释放tab
//}
}
}

privatevoid btnExit_Click(object sender, EventArgs e)
{
keyboardHook.Stop();
Application.Exit();
}
}

程序界面截图

posted @ 2011-01-20 19:03  事理  阅读(2659)  评论(1编辑  收藏  举报