I have winapi c# to save webpage as pdf. Application uses control + P on webpage and hit enter. My default printer is "nuance pdf" and I want to save the file as pdf. My code looks as below:
static class Program
{
[DllImport("user32.dll")]
public static extern int SetForegroundWindow(IntPtr hWnd);
[DllImport("User32.dll")]
public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, string lParam);
[DllImport("user32.dll")]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll")]
public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
[STAThread]
static void Main()
{
Boolean Check = true;
string text = "MyFileName";
while (Check)
{
Process[] processes = Process.GetProcessesByName("iexplore");
foreach (Process proc in processes)
{
SetForegroundWindow(proc.MainWindowHandle);
SendKeys.SendWait("^(p)");
SendKeys.SendWait("{ENTER}");
var handle = FindWindow(null, "Save As");
Console.WriteLine("handle {0}", handle);
//SendMessage(handle, 0x000C, IntPtr.Zero, text);
SendKeys.SendWait("{ENTER}");
}
Check = false;
}
}
}
This code saves the file name as "https___www.google.pdf". I would like to change the file name (highlighted).
How do I do that? Any pointers? Thanks for helping out.