> You can use the Send or SendWait methods of the System.Windows.Forms.SendKeys class to send any key-combination to the active application. E.g. to send Alt+F you would use the code:
>
[quoted text clipped - 4 lines]
> > From mine application I start another win-app using Process.Start(). Normally, when using the keyboard I can press Alt-F to access the file menu. How can I access the menu from within the first app using Process.StandardInput? Or, how can I send the Alt-key to this app?
> > Thanks in advance.
SendKeys always sends the keys to the active application. You need to wait for notepad to be able to receive input. The following code seems to work. It waits 3 seconds for notepad to enter idle state:
Process myProc = new Process();
myProc.StartInfo.FileName = @"notepad.exe";
myProc.StartInfo.UseShellExecute = false;
myProc.StartInfo.RedirectStandardInput = true;
myProc.Start();
if (myProc.WaitForInputIdle(3000))
SendKeys.SendWait("%F");
'+F' does not seem to work so I may have misinformed you in my previous post. Use '%F' instead as in the code above.
Regards, Jakob.
> Thanks,
> but I cannot use SendKeys. I have a console app which starts a windows app with code like:
[quoted text clipped - 18 lines]
> > > From mine application I start another win-app using Process.Start(). Normally, when using the keyboard I can press Alt-F to access the file menu. How can I access the menu from within the first app using Process.StandardInput? Or, how can I send the Alt-key to this app?
> > > Thanks in advance.
Edward - 28 Jun 2004 12:27 GMT
Thanks,
The problem I had was getting the called application to the foreground. Works now.
Edward
> SendKeys always sends the keys to the active application. You need to wait for notepad to be able to receive input. The following code seems to work. It waits 3 seconds for notepad to enter idle state:
>
[quoted text clipped - 32 lines]
> > > > From mine application I start another win-app using Process.Start(). Normally, when using the keyboard I can press Alt-F to access the file menu. How can I access the menu from within the first app using Process.StandardInput? Or, how can I send the Alt-key to this app?
> > > > Thanks in advance.
Jeff Johnson [MVP: VB] - 28 Jun 2004 17:06 GMT
> '+F' does not seem to work so I may have misinformed you in my previous
> post. Use '%F' instead as in the code above.
+ would mean Shift, % Alt, and ^ Ctrl.
psduckie - 28 Dec 2004 21:51 GMT
This is totally unrelated to the Alt-key, but it IS related to the post Mr.
Johnson made. I am writing an app that is supposed to send Ctrl+S to
whatever app is in the foreground. Thanks.
> > '+F' does not seem to work so I may have misinformed you in my previous
> > post. Use '%F' instead as in the code above.
>
> + would mean Shift, % Alt, and ^ Ctrl.