如何获取另一个进程MessageBox的消息
How to get message of another process MessageBox?
另一个应用程序有时显示标题为"Test"的MessageBox和MessageBox体内的一些消息,我怎么能从另一个应用程序(写在c++或c#什么)得到这个消息,然后关闭它?c#代码:
[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
public static extern int SendMessage(int hWnd,uint Msg,int wParam,int lParam);
public const int WM_SYSCOMMAND = 0x0112;
public const int SC_CLOSE = 0xF060;
for (int i = 0; i < 40; i++) // just test cycle
{
IntPtr window = FindWindow(null, "Test");
if (window != IntPtr.Zero) // ok we found it!
{
// code that reads MessageBox message?
.....
// work is done, closing
SendMessage((int)window, WM_SYSCOMMAND, SC_CLOSE, 0);
break;
}
System.Threading.Thread.Sleep(50);
}
你能帮我解决这个问题吗?我该怎么做呢? 看看这个帖子。
选择1:
你可以使用像spy++这样的API来访问其他windows控件。
选择2:
你应该使用Windows api,如EnumWindow或FindWindow,然后使用来查找目标窗口中的控件,比如你正在寻找的文本框,然后是API SetWindowText
看看这里的一些想法:为什么EnumChildWindows跳过孩子吗?也可以在Stack Overflow和中搜索这些api名称你会发现很多例子……
选择3:
我找到了这个api,它可以让你完成你的任务:http://www.programmersheaven.com/download/56171/download.aspx
相关文章:
- boost::进程间消息队列引发错误
- 在进程中对同一管道进行读取和写入时C++管道出现问题
- 是否可以通过C++扩展强制多个python进程共享同一内存
- IPC使用多个管道和分支进程来运行Python程序
- 异常属于C++中的线程还是进程
- WMI检测进程创建事件-c++
- c++多进程编写一个唯一的文件
- 如何在C++中将函数发送到另一个进程
- 在Qt Creator中,如何在连接到正在运行的进程后查看控制台输出
- WIN32:C++,为什么在WM_CLOSE上调用Messagebox函数程序正在冻结
- 终止 QProcess 不会终止子进程
- 将返回值从 exe 传递到 bat,并将其传递给 C# 中的进程
- COM :是否可以查看是否存在对我的某个 COM 对象的进程外引用?我可以释放它吗?
- Windows 进程间同步类似事件?
- 在挂钩启动新线程时解除挂钩进程
- pclose() 不会给我进程退出代码
- 运行代码时,c++ 会终止进程
- 可以读入进程内存的最大块大小是多少?
- 枚举进程模块在有效句柄上返回无效句柄
- 如何获取另一个进程MessageBox的消息