检测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生成工具哪些支持PDF文档导入?
人工智能·ai·pdf·powerpoint·办公
MindUp3 小时前
Word 转 PPT 自动化实践:8 款 AI 生成工具的自然语言处理与排版效果横向评测
人工智能·word·powerpoint
LearnYard2 天前
自然语言驱动的数据图表生成:几款工具功能对比实践
数据库·百度·powerpoint
MindUp2 天前
告别排版焦虑:从 PPT 模板到 AI 生成工具的个人使用体验与效率对比
人工智能·powerpoint
fo安方5 天前
视频——工具——视频——ppt——AI生成ppt
人工智能·powerpoint
E_ICEBLUE5 天前
Python 办公自动化:将 PowerPoint (PPT/PPTX) 转换为 PDF 【全面指南】
python·pdf·powerpoint
皮皮虾❀5 天前
千问办公+Office一站式生成+原生编辑一体化实战:从“AI生成文档格式错乱”到“PPT/Word/Excel直接出成品可商用”的交付型AI落地路径
人工智能·word·powerpoint
Claire_887 天前
PPTX排版美化实测:三款AI工具对内容解析与导出编辑性的影响
powerpoint
LearnYard7 天前
年中汇报 PPT 制作,我的 AI 辅助工具横向测评与选型建议
人工智能·powerpoint
AI分享猿7 天前
从大纲到成稿:百智云PPT如何用“一段文字“驱动整套演示文稿
ai·powerpoint·ppt