How to close popups

Programming and macros
Jordan Brown
Posts: 26
Joined: Wed Jul 21, 2021 3:20 pm
Answers: 0
x 6
x 2

How to close popups

Unread post 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,
User avatar
CT-Simo
Posts: 19
Joined: Mon Oct 24, 2022 11:17 am
Answers: 0
x 7
x 18

Re: How to close popups

Unread post 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.
Product Manager, CUSTOMTOOLS for SOLIDWORKS
Over decade of experience around SW, PDM, and related ERP integrations.
Tech-oriented; once a programmer, always a programmer.

https://www.customtools.info/
https://www.youtube.com/user/CustomTools4SW/
User avatar
josh
Posts: 304
Joined: Thu Mar 11, 2021 1:05 pm
Answers: 16
x 22
x 514

Re: How to close popups

Unread post 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.
Post Reply