检测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();
        }
    }
}
相关推荐
ms365copilot1 天前
Copilot直接读取Excel,一键生成完整数据汇报PPT
powerpoint·excel·copilot
小e说服饰1 天前
2026年AI自动生成PPT工具推荐
人工智能·powerpoint
中科致研zkzhiyan2 天前
锚定评委评审视角,构建科研重点项目申报答辩PPT闭环逻辑框架
信息可视化·powerpoint·ppt
民乐团扒谱机4 天前
【微科普】一文搞懂AI对话平台公式复制差异:DeepSeek一键粘贴PPT可编辑,豆包复制仅得到LaTeX源码底层原理
人工智能·ai·powerpoint·ai写作·deepseek
Metaphor6928 天前
使用 Python 在 PowerPoint 中创建折线图和条形图
python·信息可视化·powerpoint·图表
OpenApi.cc9 天前
Mocode PPT Model
powerpoint
一个处女座的程序猿11 天前
Agent之Skill:dashi-ppt-skill的简介、安装和使用方法、案例应用之详细攻略
powerpoint·agent·ppt-skill
MindUp17 天前
AI生成PPT工具的技术选型:从模板填充到智能体协同的演变
人工智能·powerpoint
念雨思18 天前
每日穿搭助手:鸿蒙AI应用开发实战——AI衣橱,每日穿搭不再愁
人工智能·华为·powerpoint·harmonyos·鸿蒙
ZZZMMM.zip19 天前
演示架构师-PPT大纲生成的HarmonyOS开发实践
人工智能·华为·powerpoint·harmonyos·鸿蒙·鸿蒙系统