简体   繁体   中英

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM