从 vb.net 关闭模式弹出窗口?

发布于 2024-08-15 03:18:42 字数 611 浏览 8 评论 0原文

我想等待并关闭另一个应用程序的模式表单(弹出窗口),一旦它出现。我想从 VB.NET 执行此操作,但 C# 中的建议应该很容易翻译。

我可以在我的应用程序中对模式弹出窗口的标题进行硬编码,因为它又长又独特。我想要做的是模拟用户单击表单上的关闭(“X”)按钮,或单击表单的默认 Tab 键顺序 0 按钮。两者都可以。

除了标题栏的标题之外,也许我需要有关模式弹出窗口的更多信息?无论如何,将其用作该模式形式的唯一标识符是安全的。我还希望该代码在第一个关闭弹出窗口的事件发生时立即终止检查。

我相信这是微不足道的,但我找不到任何现成的信息。微软说我不应该发送 WM_CLOSE 到模态弹出窗口,因为它会调用 DestroyWindow() 而不是 EndDialog(),但说实话我什至不知道“发送WM_CLOSE”到“窗口”意味着什么=/

感谢您分享一些大师的知识! :D

P.S.:这在 AutoHotkey 中可能是微不足道的。我感觉很糟糕,不知道它,我知道我需要它

I want to wait for and close a modal form (a popup) from another application, as soon as it appears. I want to do this from VB.NET, but suggestions in C# should be easily translateable.

I can hard-code the modal popup's caption in my app, since it's long and unique. What I want to do is simulate either the user clicking on the close ("X") button on the form, or a click on the defeault, tab-order 0 button of the form. Either would work.

Maybe I need more info about the modal popup other than the title bar's caption? In any case, it's safe to use it as an unique identifier of that modal form. I also want that code to terminate checking as soon as the first event of closing the popup happens.

I believe it's trivial, but I can't find any ready info on that. Microsoft says I should not send WM_CLOSE to the modal popup, since it will call DestroyWindow() instead of EndDialog(), but to be honest I don't even know what "sending WM_CLOSE" to the "window" means =/

Thanks for sharing a bit of guru-ness! :D

P.S.: This may be trivial in AutoHotkey. I feel lame not knowing it, I know I need it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

嗳卜坏 2024-08-22 03:18:42
IntPtr handle = FindWindow(null, "Dialog_Title");
SendMessage(handle, WM_NCDESTROY, 0, 0);

这应该关闭对话框

IntPtr handle = FindWindow(null, "Dialog_Title");
SendMessage(handle, WM_NCDESTROY, 0, 0);

This should close the dialog

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文