目前我正在使用我的C#/
WPF应用程序打开文件
- System.Diagnostics.Process.Start("C:\ .... ");
应用程序窗口是否处于全屏等状态取决于应用程序的上一个实例在关闭时的状态(例如,如果在全屏时关闭它,则会全屏打开一个新实例)
我要做的是在Excel中打开一个文件并使其全屏显示.我查看Excel的命令行开关,似乎相当有限,因为我无法通过将Application.DisplayFullScreen = True添加到VBA模块来修改excel文件.
编辑:不清楚,但我打算在全屏模式下打开它(没有功能区等),没有最大化.
Edit2:键序列为alt v,u.寻找一种方法来使用SendKeys将密钥序列发送到excel窗口
解决方法
看起来你可以使用SendKeys.
http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.send.aspx
编辑:这段代码对我有用
一定要#include System.Windows.Forms以及其他所需的东西.
- [DllImport("user32.dll")]
- static extern bool ShowWindow(IntPtr hWnd,int nCmdShow);
- public void Go()
- {
- Process excel = new Process();
- excel.StartInfo.FileName = @"C:\Test.xlsx";
- excel.Start();
- // Need to wait for excel to start
- excel.WaitForInputIdle();
- IntPtr p = excel.MainWindowHandle;
- ShowWindow(p,1);
- SendKeys.SendWait("%(vu)");
- }
看到这个SO帖子:
How to open a PDF file by using Foxit/Adobe in full screen mode?