How to send ALT + SPACE key using sendkey method?

I am implementing a desktop application where I want to send a keyboard shortcut ALT+SPACE

, but I cannot find a way to do it.

I am doing this to automatically handle the following tasks:

  • enter the tracert command in the command line
  • copy the result
  • paster result in notepad

Can anyone help me with this ??

+3


source to share


2 answers


try it

System.Windows.Forms.SendKeys.Send("% ");

      



Edit
Usage is a SendKeys

bit "hacked". I would suggest using the Process class instead, something like below

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();
}

      

+4


source


Just check

<hit>% {space} hit>



SendKeys.Send("% ");

// {SPACE} is invalid, so use normal ""

This should emulate pressing Alt + Space

0


source







All Articles