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);
分享到:
相关推荐
C# 调用 Windows Api实现自动打开QQ输入窗体,输入账号密码,进行登录功能
获取屏幕坐标的C#源代码,鼠标在哪里 就能现实鼠标所在位置的屏幕坐标,供c#爱好者学习之用
用c#调用windowsapi实现自动登录.pdf
C#中调用Windows API的要点
安装 Windows 自动化 API 3.0 后,Visual Studio 2010 的运行速度更快。
windows api实现屏幕截屏处理,并保存成jpg/bmp等格式文件,代码在vs2008运行无误,望能给大家提供帮助!
C#自动化测试工具编写-WindowsFormsTest: 在日常编码过程中,我们常常会进行自动化测试。这里的自动化测试不是指单元测试,而是模拟人工输入...所以,比较高效的一个做法是,调用WINDOWS API,自己动手写编码来实现。
主要是调用Windows API user32.dll动态库,将其引入到项目之中,此为非托管代码,使用DllImport特性即可。这里也简单介绍下user32动态库,user32.dll是Windows用户界面相关应用程序接口,用于包括Windows处理,基本...
1.Windows API常用函数使用说明; 2.VB.NET常用Windows API常用函数声明; 3.可生成自动操作Windows系统的脚本等;
windows API教程 用API函数控制光驱的开关 采用API实现的文件拖放 创建和删除快捷方式 建立文件关联 模拟一次鼠标事件 闪烁的标题栏 实现平面工具栏 使窗体右上角的X按钮失效 使用超链接和发送电子邮件Email 使用...
Windows API实现ODBC的自动设置,可以让ODBC不用配置
自己编写,包含几乎所有Windows Api 函数定义声明,还有结构定义声明, VB.net C# 可真接使用,包含自动整理,错误修改等功能.欢迎大家指正,本人邮箱726572709@QQ.com.
自动生成PInvoke调用Windows API的C#函数声明... 可以在开发跨语言,com互操作,跨语言dll调用声明类型时作为参考工具
基于windowsAPI的vb编程题自动评分系统的研究与实现
通过windows API 获取闲置计算机的时间实现锁定计算机和关机。
Windows下一个比较完美的线程池实现和示例 本线程池提供了如下功能: 1.能根据任务个数和当前线程的多少在最小/最大线程个数之间自动调整(Vista后的系统有 SetThreadpoolThreadMaximum 等函数有类似功能); 2.能方便...
在日常编码过程中,我们常常会进行自动化测试。这里的自动化测试不是指单元测试,而是模拟人工输入来进行快速的、高并发的测试。...所以,比较高效的一个做法是,调用WINDOWS API,自己动手写编码来实现。
windows API 在C#、VB、VB.Net的自动生成,不需要在为API声明中如何在net里面的对应头疼!
Rust 的 Windows API 文档这是Rust for Windows项目的实验性文档生成器。文档在这里发布:https://microsoft.github.io/windows-docs-rs/modules crate 生成要在 bindings crate 中使用的模块路径列表。bindings箱...
本程序给那些需要做桌面扩展,而又不知道如何使用API扩展的朋友 本程序会自动扩展第二桌面的桌面,运行时无界面,成功后退出 功能:开启和关闭win扩展桌面 参数: 直接运行则扩展桌面、参数-0、/0、0 是,取消扩展...