检测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();
        }
    }
}
相关推荐
TonyLee0175 小时前
AI制作PPT(codex+ppt-master skills)
人工智能·powerpoint
鲲穹AI种草6 小时前
多份演示文稿整理耗时费力,多款 PPT 批量处理工具能力客观记录
powerpoint·批量处理图片
shionhana8 小时前
从资料到演示稿:AI 生成 PPT 的工作流拆解
人工智能·ai·powerpoint
Wang's Blog3 天前
Vibe Coding一人即团队系列59:基于PPTmaster与Claude Desktop的本地可编辑PPT自动化生成方案
运维·自动化·powerpoint
Wang's Blog3 天前
Vibe Coding一人即团队系列61: AI驱动PPT全自动生成实战——配图集成、模板定制与多源内容适配
人工智能·powerpoint
qq_425516183 天前
一句话生成PPT的录音APP:会议材料生成能力对比
大数据·人工智能·powerpoint
ms365copilot4 天前
Copilot PowerPoint品牌套件模板设置教程
powerpoint·copilot
AcaDesign5 天前
大禹水利科学技术奖ppt制作案例|科技进步奖|技术发明奖|自然科学奖|WordinPPT
科技·powerpoint
DevOpenClub6 天前
Markdown、HTML 和 PPT 如何稳定交付:文档转换任务的幂等发布流程
开发语言·前端·c#·html·powerpoint
课件帮6 天前
教师考编面试模拟授课课件怎么做?课件帮AI生成教案+PPT+数字人试讲
人工智能·面试·powerpoint