目前我正在使用 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?
关于c# - 如何从 "Full Screen"中的 C#/WPF 打开 Excel 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20337539/