简体   繁体   中英

How can I express this VB code in C#?

How can I convert this from vb to c#?

 Call WshShell.Run( "API_CALLBACK.exe", 0, True )  
 WScript.Sleep(10000)  

 WshShell.SendKeys("{ENTER}")  
 WScript.Sleep(3000)  
 WshShell.SendKeys("%S")  
 WScript.Sleep(3000)  
 WshShell.SendKeys("%Y")  

Thx
It is process.start("API_CALLBACK");? how to do with .sendkey?

I'm not going to write the code for you, but here are the things you'll need:

One way to star a process in .NET is the Process.Start method. You'll have to look for the overload the does what you need it to.

Process.Start("API_CALLBACK.exe");

There is also a handy SendKeys class in the .NET framework.

SendKeys.Send("{ENTER}");

And further, you can put the current thread to sleep with the Thread.Sleep method.

Thread.Sleep(1000);
WshShell.Run("API_CALLBACK.exe", 0, true);
WScript.Sleep(10000);

WshShell.SendKeys("{ENTER}");
WScript.Sleep(3000);
WshShell.SendKeys("%S");
WScript.Sleep(3000);
WshShell.SendKeys("%Y");

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