如何通过 SendKeys.Send() 方法发送 Ctrl+S 以在外部应用程序中保存文件?

How to send Ctrl+S through SendKeys.Send() method to save a file in an external application?

我需要使用 SendKeys.Send() 方法在外部应用程序中保存一个文件。需要发送的key是Ctrl+S.

我写了下面的代码,但它不起作用:

SendKeys.SendWait("^%s?");  // to get the Save As dialog
Thread.Sleep(5000);
SetForegroundWindow(FindWindow(null, "Save As"));
Thread.Sleep(5000);
SendKeys.SendWait("xyz"); // Sending FileName

我相信你需要使用:

SendKeys.SendWait("^(s)");

而不是:

SendKeys.SendWait("^%s?");

查看 https://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.send(v=vs.110).aspx 了解更多信息。