检测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();
        }
    }
}
相关推荐
SpaceAIGlobal2 天前
AI 生成 PPT 工具深度评测与选型指南
人工智能·powerpoint
一头爱吃肉的牛3 天前
2026年10款AI PPT工具横向评测:内容准确性、生成速度、模板丰富度对比
人工智能·powerpoint
取个鸣字真的难4 天前
Image2 生成 PPT 的最后分水岭:Prompt
人工智能·prompt·powerpoint
m0_547486665 天前
《数字图像处理:使用MATLAB分析与实现》全套课件PPT
开发语言·matlab·powerpoint
ShyanZh5 天前
【skill】HTML-PPT:36主题31布局的专业HTML演示文稿工作室
ai·html·powerpoint·html-ppt
Sour5 天前
【无标题】aPPT 翻译后保留版式的流程:文本框、图片、母版和动画检查
pdf·powerpoint
ShyanZh6 天前
【skill】HTML PPT Skill:用 Claude Code 一句话生成专业演示文稿
前端·ai·html·powerpoint·skill
绎奇PPT6 天前
绎奇PPT深耕教学创新大赛,国赛 PPT 专属设计
信息可视化·powerpoint·ppt
一起逃去看海吧7 天前
openclaw(接通外部生成PPT)
powerpoint
一晌小贪欢7 天前
第26节:自动化办公——利用 Python 自动生成动态分析报告 (PPT/PDF)
开发语言·python·数据分析·自动化·powerpoint·pandas·数据可视化