开发者

Closing a modal popup from vb.net?

开发者 https://www.devze.com 2022-12-14 06:06 出处:网络
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 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 DestroyWi开发者_开发问答ndow() 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.


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

This should close the dialog

0

精彩评论

暂无评论...
验证码 换一张
取 消