Comment puis-je par programmation appuyez sur Entrée?
J'ai une console C# programme qui commence à la calculatrice, et simule les touches. Comment puis-je par programmation appuyez sur la touche Entrée?
[DllImport("USER32.DLL", CharSet = CharSet.Unicode)]
public static extern IntPtr FindWindow(string lpClassName,
string lpWindowName);
//Activate an application window.
[DllImport("USER32.DLL")]
public static extern bool SetForegroundWindow(IntPtr hWnd);
//Send a series of key presses to the Calculator application.
private void StartCalculator()
{
Process.Start("calc.exe");
IntPtr calculatorHandle = FindWindow("CalcFrame","Calculator");
if (calculatorHandle == IntPtr.Zero)
{
return;
}
SetForegroundWindow(calculatorHandle);
SendKeys.SendWait("111");
SendKeys.SendWait("*");
SendKeys.SendWait("11");
SendKeys.SendWait("=");
SendKeys.SendWait(" ");//how press enter?
}
Pour référence : stackoverflow.com/questions/10286086/...
OriginalL'auteur user3231442 | 2014-08-20
Vous devez vous connecter pour publier un commentaire.
Prises de SendKeys.Méthode D'Envoi
ou
"{ENTER}"
vous avez besoin, pas"ENTER"
il utilise {Enter} 🙂
OriginalL'auteur nsgocev