Advertisement
SVXX

Clicking A MessageBox

May 28th, 2013
393
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.47 KB | None | 0 0
  1.             List<IntPtr> result = new List<IntPtr>();
  2.             GCHandle listHandle = GCHandle.Alloc(result);
  3.             try
  4.             {
  5.                 IntPtr Window_hWnd = CloseMessageBox.FindWindowByCaption("#32770", "LastQuestion"); //Could use null as the first argument too. "#32770" represents classname Dialog.
  6.                 CloseMessageBox.EnumChildWindows(Window_hWnd, (hWnd, lParam) =>
  7.                 {
  8.                     StringBuilder sb = new StringBuilder();
  9.                     foreach (var control in GCHandle.FromIntPtr(lParam).Target as List<IntPtr>)
  10.                     {
  11.                         CloseMessageBox.GetWindowText(control, sb, 250);
  12.                         if (sb.Equals("&No"))
  13.                         {
  14.                             CloseMessageBox.PostMessage(hWnd, CloseMessageBox.MouseDown, 0, 0);
  15.                             CloseMessageBox.PostMessage(hWnd, CloseMessageBox.MouseUp, 0, 0);
  16.                         }
  17.                     }
  18.                     return false;
  19.                 }, GCHandle.ToIntPtr(listHandle));
  20.                 //if (hWnd != IntPtr.Zero)
  21.                 //CloseMessageBox.PostMessage(Window_hWnd, CloseMessageBox.SysCommand , CloseMessageBox.Close, 0);
  22.             }
  23.             catch (Exception e)
  24.             {
  25.                 MessageBox.Show(e.ToString());
  26.             }
  27.             finally
  28.             {
  29.                 if (listHandle.IsAllocated)
  30.                     listHandle.Free();
  31.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement