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

12.2k views Asked by At

I need to save a file which is in an external application using SendKeys.Send() method. The keys needed to be sent are Ctrl+S.

I wrote the below code, but it does not work:

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
1

There are 1 answers

0
James Cowell On BEST ANSWER

I believe you need to use:

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

Instead of:

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

Have a look at https://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.send(v=vs.110).aspx for more information.