private static void DoCloseOpenFileDialog(NktRemoteBridge remoteBridge, Process proc) { IntPtr hWnd; try { hWnd = remoteBridge.FindWindow(proc.Id, IntPtr.Zero, "Open", "#32770", false); if (hWnd == IntPtr.Zero) hWnd = remoteBridge.FindWindow(proc.Id, IntPtr.Zero, "Abrir", "#32770", false); if (hWnd == IntPtr.Zero) { Console.WriteLine("Cannot find OpenFileDialog window"); return; } //we can try sending a WM_COMMAND with IDOK but we will try to find the ok button and send //fake lbuttondown/up to test more methods instead. hWnd = remoteBridge.GetChildWindowFromId(proc.Id, hWnd, 1); if (hWnd == IntPtr.Zero) { Console.WriteLine("Cannot find OpenFileDialog's OK button"); return; } remoteBridge.PostMessage(proc.Id, hWnd, 0x0201, IntPtr.Zero, IntPtr.Zero); //WM_LBUTTONDOWN remoteBridge.PostMessage(proc.Id, hWnd, 0x0202, IntPtr.Zero, IntPtr.Zero); //WM_LBUTTONUP } catch (System.Exception ex) { Console.WriteLine(ex.ToString()); } return; }