检测PowerPoint是否进入了PPT全屏放映模式

豆包给了一段代码,可以检测PowerPoint是否进入了PPT全屏放映模式,VS2022,winform4.8

cs 复制代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;


using Microsoft.Office.Interop.PowerPoint;
using Microsoft.Office.Core;

namespace PowerPointTool
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
      
        }

        /// <summary>
        /// 检测 PowerPoint 是否处于全屏放映模式
        /// </summary>
        public static bool IsPowerPointFullScreen()
        {
            Microsoft.Office.Interop.PowerPoint.Application pptApp = null;
            try
            {
                // 获取正在运行的 PowerPoint 实例
                pptApp = (Microsoft.Office.Interop.PowerPoint.Application)System.Runtime.InteropServices.Marshal.GetActiveObject("PowerPoint.Application");

                if (pptApp.SlideShowWindows.Count > 0)
                {
                    foreach (SlideShowWindow window in pptApp.SlideShowWindows)
                    {
                        // 判断是否全屏
                        if (window.IsFullScreen == MsoTriState.msoTrue)
                            return true;
                    }
                }
                return false;
            }
            catch
            {
                // 没有运行 PowerPoint
                return false;
            }
            finally
            {
                // 释放 COM 对象,避免进程残留
                if (pptApp != null)
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(pptApp);
                }
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            label1.Text = IsPowerPointFullScreen().ToString();
        }
    }
}
相关推荐
小幂同学1 小时前
AIPPT 使用说明:从主题输入或文档大纲生成 PPT!
powerpoint
RichardLau_Cx11 小时前
PPT工具选型指南:WPS、PowerPoint、Canva 与 AI 办公助手(豆包_千问_WorkBuddy)到底怎么选?
人工智能·powerpoint·wps
白帽攻防录2 天前
SRC 挖洞:PowerPoint 四个 RCE,预览窗格怎么变成零点击入口
网络安全·powerpoint·文档安全
学术 学术 Fun2 天前
截图转可编辑 PPT:旧流程图改步骤,不再靠白色方块遮字
powerpoint·流程图
qq_364682153 天前
Android APP会议记录工具生成图文内容
人工智能·powerpoint
SunnyDays10113 天前
如何使用 Java 提取 PPT 中的文字:整份文档、指定幻灯片与表格内容
java·powerpoint
传人once3 天前
从 PPT 到可交互原型:用 AI 做小程序原型的实践 | 深度实践版
人工智能·powerpoint·交互
中科致研zkzhiyan5 天前
大学教授职称晋升汇报 PPT 设计指南
信息可视化·powerpoint·ppt
虎头金猫5 天前
从上传PPT到观众远程打开互动页面:Claper在CentOS 7上的Docker部署、互动组件设置与固定访问地址实战
linux·运维·网络·人工智能·docker·centos·powerpoint
启雀AI5 天前
演讲式 AI 陪练引擎设计:PPT 内容解析、翻页节奏感知与多模态评分的工程实现
人工智能·powerpoint·培训saas平台·企业lms·ai陪练