如何使用sendkey方法发送ALT + SPACE键?

Vis*_*har 4 c# windows-applications

我正在实现一个桌面应用程序,我想在其中发送一个ALT+SPACE组合键,但我找不到任何方法来执行此操作.

我正在实现这个以自动处理以下任务:

  1. 在命令提示符下输入tracert命令
  2. 复制结果
  3. 把结果贴在记事本上

谁能帮我这个..?

Ash*_*nko 5

试试这个

System.Windows.Forms.SendKeys.Send("% ");
Run Code Online (Sandbox Code Playgroud)

编辑
使用SendKeys有点'hacky'.相反,我建议使用Process类,如下所示

public string GetTracert(string ip)
{
    Process p = new Process();
    p.StartInfo.FileName = "tracert";
    p.StartInfo.Arguments = "123.123.123.123";
    p.StartInfo.RedirectStandardOutput = true;
    p.Start();

    return p.StandardOutput.ReadToEnd();
}
Run Code Online (Sandbox Code Playgroud)