windows API 自动登录
2011-12-30 12:14
113 查看
private void button2_Click(object sender, EventArgs e)
{
System.Diagnostics.Process myProcess = System.Diagnostics.Process.Start(@"E:\网店管家(企业版)2.1\cc.exe");
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
myProcess.WaitForInputIdle(10000);
SearchWindow();
// SendKeys.SendWait("{Enter}");
}
private void SearchWindow()
{
IntPtr ParenthWnd = new IntPtr(0);
IntPtr EdithWnd = new IntPtr(0);
IntPtr Con = new IntPtr(0);
IntPtr pw = new IntPtr(0);
//查到窗体,得到整个窗体
ParenthWnd = FindWindow("TForm_login", "电话服务平台【登陆】");//用spy++这个软件可以得到(TForm_login)类名和电话服务平台【登陆】下载地址http://download.csdn.net/detail/bychentufeiyang/3984135
//判断这个窗体是否有效
if (!ParenthWnd.Equals(IntPtr.Zero))
{
//得到User Name这个子窗体,并设置其内容
EdithWnd = FindWindowEx(ParenthWnd, IntPtr.Zero, "TPanel", "");
IntPtr EdithWnd1 = FindWindowEx(EdithWnd, IntPtr.Zero, "TsuiComboBox", "");
SendMessage(EdithWnd1, WM_SETTEXT, (IntPtr)0, "wangw");
IntPtr EdithWnd2 = FindWindowEx(EdithWnd, IntPtr.Zero, "TsuiMaskEdit", "");
IntPtr EdithWnd3 = FindWindow("TForm_TelReg", "来电受理");
SendMessage(EdithWnd2, WM_SETTEXT, (IntPtr)0, "123456");
SendKeys.SendWait("{Enter}");
}
}
const int WM_GETTEXT = 0x000D;
const int WM_SETTEXT = 0x000C;
const int WM_CLICK = 0x00F5;
const int WM_SYSCOMMAND = 0x0112;
const int SC_MAXIMIZE = 0xF030;
[DllImport("user32.dll", EntryPoint = "FindWindow")]
private extern static IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
private static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImport("user32.dll")]
static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
private static extern IntPtr GetForegroundWindow(); //WINAPI 获取当前活动窗体的句柄
[DllImport("User32.dll", EntryPoint = "SendMessage")]
private static extern int SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, string lParam);
[DllImport("user32.dll")]
private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
[DllImport("user32.dll", EntryPoint = "FindWindow")]
private extern static IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
private static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImport("user32.dll")]
static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
private static extern IntPtr GetForegroundWindow(); //WINAPI 获取当前活动窗体的句柄
[DllImport("User32.dll", EntryPoint = "SendMessage")]
private static extern int SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, string lParam);
[DllImport("user32.dll")]
private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
{
System.Diagnostics.Process myProcess = System.Diagnostics.Process.Start(@"E:\网店管家(企业版)2.1\cc.exe");
myProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
myProcess.WaitForInputIdle(10000);
SearchWindow();
// SendKeys.SendWait("{Enter}");
}
private void SearchWindow()
{
IntPtr ParenthWnd = new IntPtr(0);
IntPtr EdithWnd = new IntPtr(0);
IntPtr Con = new IntPtr(0);
IntPtr pw = new IntPtr(0);
//查到窗体,得到整个窗体
ParenthWnd = FindWindow("TForm_login", "电话服务平台【登陆】");//用spy++这个软件可以得到(TForm_login)类名和电话服务平台【登陆】下载地址http://download.csdn.net/detail/bychentufeiyang/3984135
//判断这个窗体是否有效
if (!ParenthWnd.Equals(IntPtr.Zero))
{
//得到User Name这个子窗体,并设置其内容
EdithWnd = FindWindowEx(ParenthWnd, IntPtr.Zero, "TPanel", "");
IntPtr EdithWnd1 = FindWindowEx(EdithWnd, IntPtr.Zero, "TsuiComboBox", "");
SendMessage(EdithWnd1, WM_SETTEXT, (IntPtr)0, "wangw");
IntPtr EdithWnd2 = FindWindowEx(EdithWnd, IntPtr.Zero, "TsuiMaskEdit", "");
IntPtr EdithWnd3 = FindWindow("TForm_TelReg", "来电受理");
SendMessage(EdithWnd2, WM_SETTEXT, (IntPtr)0, "123456");
SendKeys.SendWait("{Enter}");
}
}
const int WM_GETTEXT = 0x000D;
const int WM_SETTEXT = 0x000C;
const int WM_CLICK = 0x00F5;
const int WM_SYSCOMMAND = 0x0112;
const int SC_MAXIMIZE = 0xF030;
[DllImport("user32.dll", EntryPoint = "FindWindow")]
private extern static IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
private static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImport("user32.dll")]
static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
private static extern IntPtr GetForegroundWindow(); //WINAPI 获取当前活动窗体的句柄
[DllImport("User32.dll", EntryPoint = "SendMessage")]
private static extern int SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, string lParam);
[DllImport("user32.dll")]
private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
[DllImport("user32.dll", EntryPoint = "FindWindow")]
private extern static IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
private static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImport("user32.dll")]
static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
private static extern IntPtr GetForegroundWindow(); //WINAPI 获取当前活动窗体的句柄
[DllImport("User32.dll", EntryPoint = "SendMessage")]
private static extern int SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, string lParam);
[DllImport("user32.dll")]
private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
相关文章推荐
- C#调用Windows API实现自动登录(续)
- C#中使用Windows API控制阿里旺旺自动登录 的程序源代码
- 用C#调用Windows API实现自动登录
- C#调用Windows API实现自动登录
- C#调用Windows API实现自动登录
- 用C#调用Windows API实现自动登录
- C#调用Windows API实现自动登录
- C#中使用Windows API控制阿里旺旺自动登录 的程序源代码
- C#调用Windows API实现自动登录
- C#调用Windows API实现自动登录
- C#调用Windows API实现自动登录(续)
- C#调用Windows API实现自动登录
- 如何实现自动登录Linux进图形界面
- 如何设置windows系统自动登录的方法
- 配置phpmyadmin使登录时可填写IP管理多台MySQL 连接多个数据库 自动登录
- JavaScript基础——实现自动登录的安全提醒
- Windows:修改注册表让Windows XP自动登录
- linux 嵌入式 自启动 系统自动登录-自动启动程序或脚本
- 华为交换机在Telnet登录下自动显示接口信息
- Android:利用SharedPreferences实现自动登录