Click A MessageBox button programmatically
问题 As the title suggests, I'm trying to simulate a button-click in a MessageBox programmatically. I earlier tried to close the MessageBox by finding its handle via its caption, and applying WM_CLOSE or SC_CLOSE in SendMessage() . However, due to the presence of Yes/No buttons, that did not work (the X button is grayed out). Now I'm trying to click the No button as follows -: List<IntPtr> result = new List<IntPtr>(); GCHandle listHandle = GCHandle.Alloc(result); try { IntPtr Window_hWnd =