为什么第二个函数不被执行
程序很简单 就是打开 然后登陆
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
namespace ConsoleApplication2
{
class Program
{
const int WM_SETTEXT = 0x000C;
const int WM_LBUTTONDOWN = 0x0201;
const int WM_LBUTTONUP = 0x0202;
const int WM_CLOSE = 0x0010;
public static string user = "账号";
public static string pass = "123456";
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("User32.dll", EntryPoint = "SendMessage")]
private static extern int SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, string lParam);
[DllImport("User32.dll ")]
public static extern IntPtr FindWindowEx(IntPtr parent, IntPtr childe, string strclass, string FrmText);
static void Main(string[] args)
{
open();
login();
}
private static void open()
{
Process pr = new Process();
pr.StartInfo.FileName = @"D:\Program Files\11game\11Game.exe";
pr.Start();
}
private static void login()
{
IntPtr hwnd = FindWindow("#32770", "11对战平台 - 1.0.4.3");
IntPtr htextbox = FindWindowEx(hwnd, IntPtr.Zero, "ComboBox", null);
IntPtr htextbox2 = FindWindowEx(hwnd, htextbox, "EDIT", null);//填上次获得的句柄,可以得到下一个的句柄
IntPtr hbutton = FindWindowEx(hwnd, IntPtr.Zero, "BUTTON", "登 录");
SendMessage(htextbox, WM_SETTEXT, IntPtr.Zero, user);
SendMessage(htextbox2, WM_SETTEXT, IntPtr.Zero, pass);
SendMessage(hbutton, WM_LBUTTONDOWN, IntPtr.Zero, null);
SendMessage(hbutton, WM_LBUTTONUP, IntPtr.Zero, null);
}
}
}