Introduction
The free CutePDF utility doesn't allow you to interact with it, the following article will explain how to overcome this limitation.
Using the code
The following snippet will illustrate how to get the main thread to press the enter button as soon as the PDF Save File dialogue is shown.
[DllImport("user32.dll")]
static extern bool PostMessage(IntPtr hWnd, UInt32 Msg, int wParam, int lParam);
private static void ConfirmPDFDialog()
{
bool found = false;
while (!found)
{
Process[] processes = Process.GetProcessesByName("CPWSave");
if (processes.Length > 0)
{
if(processes[0].MainWindowHandle != IntPtr.Zero)
{
IntPtr pFoundWindow = processes[0].MainWindowHandle;
PostMessage(pFoundWindow, 0x100, (int)Keys.Enter, 0);
found = true;
}
}
}
Thread.Sleep(500);
}