C#调用其他程序,比如控制别的程序上的按钮
2012-04-19 16:50
716 查看
[DllImport ( "user32.dll", EntryPoint = "FindWindow", SetLastError = true )] private static extern IntPtr FindWindow( string lpClassName, string lpWindowName ); [DllImport ( "user32.dll", EntryPoint = "FindWindowEx", SetLastError = true )] private static extern IntPtr FindWindowEx( IntPtr hwndParent, uint hwndChildAfter, string lpszClass, string lpszWindow ); [DllImport ( "user32.dll", EntryPoint = "SendMessage", SetLastError = true, CharSet = CharSet.Auto )] private static extern int SendMessage( IntPtr hwnd, uint wMsg, int wParam, int lParam ); [DllImport ( "user32.dll", EntryPoint = "SetForegroundWindow", SetLastError = true )] private static extern void SetForegroundWindow( IntPtr hwnd ); private void button2_Click(object sender, EventArgs e) { const uint BM_CLICK = 0xF5; //鼠标点击的消息,对于各种消息的数值,大家还是得去API手册 IntPtr hwndPhoto = FindWindow(null, "UC580Demo"); //查找拍照程序的句柄【任务管理器中的应用程序名称】 if (hwndPhoto != IntPtr.Zero) { IntPtr hwndThree = FindWindowEx(hwndCalc, 0, null, "快照"); //获取按钮快照的句柄 SetForegroundWindow(hwndPhoto); //将UcDemo程序设为当前活动窗口 System.Threading.Thread.Sleep(500); //暂停500毫秒 SendMessage(hwndThree, BM_CLICK, 0, 0);//模拟点击拍照按钮 } else { MessageBox.Show("没有启动 UcDemo"); } }
相关文章推荐
- C#调用其他程序,比如控制别的程序上的按钮 分类: .NET 2012-04-19 16:50 2216人阅读 评论(0) 收藏
- 【进程间的通信】☞项目引入——C#通过Windows API 调用其他程序、触发按钮Click事件
- 在C#中简单调用FindWindow控制其他程序
- 用C#来调用cmd命令程序,实现wifi控制的工具
- C#按钮事件中有循环,用另一个按钮控制停止,暂停,继续程序执行
- HTML按钮控制C#程序截图并查看
- C#可调用API接口来获取窗口句柄,发送消息控制其余程序窗体大小
- C#的dll被其他程序调用时,获取此dll正确的物理路径
- 用 c 调用 win-api 实现自动点击c# winform 程序 的按钮
- c# 调用c++dll挂钩其他程序线程或者进程
- C# 调用其他程序
- C# 设置当前程序调用的dll文件以及其他文件的寻址路径
- 用C#调用Windows API和其它进程通信及C# 获得另外一程序 句柄 后控制该程序 控制其透明 窗体大小
- C# 使用 Environment.GetCommandLineArgs 方法 制作*.exe和参数 供其他程序调用
- c#控制其他程序窗口位置
- C# 使用 Environment.GetCommandLineArgs 方法 制作*.exe和参数 供其他程序调用
- C#隐藏其他程序窗口以及添加最小化/最大化按钮
- c#调用命令行控制程序
- 用C#来调用cmd命令程序,实现wifi控制的工具
- C# SendMessage 控制其他进程程序