Page 1 of 1

How to close popups

Posted: Wed Nov 23, 2022 1:16 pm
by Jordan Brown
Hello,

So I have a macro that deletes an old block from a drawing and replaces it in the same location with a new block. On some drawings it works fine and on other ones I get this popup twice whenever it is run.
image.png
Does anyone know of a way to have the macro close them if/when they pop up?

I am using C#.

Thanks,

Re: How to close popups

Posted: Thu Nov 24, 2022 1:49 pm
by CT-Simo
You'll have to use WinAPI to enumerate all windows and detect the one you are interested in. Then use WinAPI again to send IDOK for the dialog. Note that all controls, labels, buttons and everything in every dialog/form IS a window, so you need to consider also performance when implementing something like that.

Look for WinAPI and P/Invoke. You'll probably need to use functions like GetClassName, GetDesktopWindow, SendMessage, FindWindow, GetWindowText, GetWindow, IsWindowVisible. You might also need to use a tool called Spy++ to get some window information about that particular messagebox so that you can easier detect it via API.

Re: How to close popups

Posted: Fri Nov 25, 2022 2:48 pm
by josh
You might have better luck figuring out what condition of the document is causing the message and preventing it by removing the condition.