[英]Determine whether Powerpoint is in Presentation mode or not
我编写了一个程序,当用户可以自己设置一个间隔时,它会弹出并播放声音。
现在,我想让Powerpoint在演示文稿模式下运行并且间隔过去时保持静音,这样在与外部观众进行演示时该程序就不会出现在屏幕顶部并播放声音。
使用的PowerPoint版本是13/10/13(12.0 / 14.0 / 15.0),我找不到确定演示模式是否正在运行的任何方法。
该程序不是PowerPoint插件,也不是普通的WPF桌面应用程序。
抱歉,如果回答我自己的问题看起来有点贪心,但我认为此答案将对遇到相同问题的人有所帮助:
只需添加名为“ Microsoft PowerPoint 15.0对象库”的COM引用-它在引用列表中显示为“ Microsoft.Office.Interop.PowerPoint”
以下代码测试了用于运行Presentation的代码,并经过测试可用于版本2007/10/13(12.0 / 14.0 / 15.0):
var PPT = new Microsoft.Office.Interop.PowerPoint.Application();
if (PPT.SlideShowWindows.Count > 0)
{ //a PowerPoint Presentation mode is currently running}
else
{//there is no PowerPoint Presentation mode running}
一些错误报告表明,如果PowerPoint根本不运行或演示模式未处于活动状态,则仅通过上述方法进行操作会导致异常,因此我对代码进行了一些修改:
private bool IsPPTPresentationRunning()
{
Process[] prozesse = Process.GetProcesses();
foreach (Process p in prozesse)
{//searches for a running PowerPoint process
if (p.ProcessName == "POWERPNT")
{
try
{
Microsoft.Office.Interop.PowerPoint.Application PPT =
new Microsoft.Office.Interop.PowerPoint.Application();
if (PPT.SlideShowWindows.Count > 0)
return true;
else
return false;
}
//Catches any exception that seems to get thrown when
// powerpoint is not in Presentation mode
catch (Exception)
{
return false;
}
}
}
return false;
}
可能对您有帮助...“如何自动控制PowerPoint幻灯片” https://code.msdn.microsoft.com/office/How-to-Automate-control-23cd2a8f
您可以检测是否有其他程序(不仅是PowerPoint)正在全屏运行。 这正是您想要的答案https://stackoverflow.com/a/3744720/1977363
访问以下链接。 我认为这会有所帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.