检测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();
        }
    }
}
相关推荐
STRUGGLE_xlf4 小时前
Codex × PPT Skill:一句话生成演示文稿
人工智能·powerpoint·智能体
数据法师4 小时前
Oh My PPT技术深度解析:本地优先的开源AI幻灯片生成器,重新定义“人机协同”式创作
人工智能·开源·powerpoint
XDevelop AI智能应用软件开发6 小时前
告别机械搬砖!如何用AI Agent一键生成“教案+PPT+交互网页”教学三件套?
人工智能·powerpoint
SunnyDays10117 小时前
使用 Python 加密、保护和签名 PowerPoint 演示文稿 (PPT)
python·powerpoint·加密 ppt·保护 ppt·给ppt添加数字签名
w1wi1 天前
【AI应用】利用AI生成优雅且可编辑PPT
人工智能·powerpoint·agi
一头爱吃肉的牛1 天前
2026年支持自定义模板的AI PPT工具测评:5款工具横向对比
人工智能·powerpoint
tedcloud1234 天前
wifi-densepose部署教程:构建无线感知AI实验环境
服务器·人工智能·系统架构·powerpoint·dreamweaver
imbackneverdie4 天前
AI生成PPT全流程攻略
人工智能·信息可视化·aigc·powerpoint·ppt·科研工具·ai生图
小付爱coding5 天前
主流PPT 生成 Skill测评排名
powerpoint
BileiX5 天前
PPT-Master使用流程
powerpoint