Is it possible to capture a Windows pop-up message box from inside a Java program?

冷暖自知 提交于 2019-12-06 13:13:44

You could be lucky. You could use JNA to call EnumerateWindows or FindWindow of the Win32 API. Then search the button via FindWindowEx.

Then "click" it by calling PostMessage and sending a BM_CLICK

You probably want to have a separate watcher thread that does all this, as your programm waits for the process to end or continue.

Sorry my answer is very rough. Dinner has priority.

No. It's just a process that's running.

Spawning anything that puts up a GUI or any other method of control that cannot be controlled via stdin/out makes little sense.

No, not directly as far as I can tell. However, you can probably do some form of asynchronous notification. For example you can have the particular app post to a topic in a JSM queue which your app could subscribe to. If you do not have the option of going the JMS route, you can use file notification based triggers. You can have the other app create a dummy file in a common directory and you can have your app monitor that directory.

Bottom line is I do not think you can capture a pop up from another process inside your process. So you will need to do some form of external/asynchronous handling to capture it.

An inelegant, but simple solution would be to time out.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!