improve:PPT模块
This commit is contained in:
@@ -1364,51 +1364,41 @@ namespace Ink_Canvas {
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// 检查所有WPS相关进程(wpp、wps、et)是否有前台窗口
|
if (wppProcess != null)
|
||||||
string[] wpsProcessNames = { "wpp", "wps", "et" };
|
|
||||||
var wpsPids = new System.Collections.Generic.HashSet<int>();
|
|
||||||
foreach (var name in wpsProcessNames)
|
|
||||||
{
|
{
|
||||||
foreach (var proc in System.Diagnostics.Process.GetProcessesByName(name))
|
bool hasVisibleWppWindow = false;
|
||||||
|
EnumWindows((hWnd, lParam) =>
|
||||||
{
|
{
|
||||||
wpsPids.Add(proc.Id);
|
try
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool hasVisibleWpsWindow = false;
|
|
||||||
EnumWindows((hWnd, lParam) =>
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
uint windowProcessId;
|
|
||||||
GetWindowThreadProcessId(hWnd, out windowProcessId);
|
|
||||||
if (wpsPids.Contains((int)windowProcessId))
|
|
||||||
{
|
{
|
||||||
// 检查窗口是否可见
|
uint windowProcessId;
|
||||||
if (IsWindowVisible(hWnd))
|
GetWindowThreadProcessId(hWnd, out windowProcessId);
|
||||||
|
if ((int)windowProcessId == wppProcess.Id)
|
||||||
{
|
{
|
||||||
// 检查窗口标题是否为空
|
if (IsWindowVisible(hWnd))
|
||||||
var windowTitle = new System.Text.StringBuilder(256);
|
|
||||||
GetWindowText(hWnd, windowTitle, 256);
|
|
||||||
var title = windowTitle.ToString().Trim();
|
|
||||||
if (!string.IsNullOrEmpty(title))
|
|
||||||
{
|
{
|
||||||
hasVisibleWpsWindow = true;
|
var windowTitle = new System.Text.StringBuilder(256);
|
||||||
return false; // 找到一个就停止枚举
|
GetWindowText(hWnd, windowTitle, 256);
|
||||||
|
var title = windowTitle.ToString().Trim();
|
||||||
|
if (!string.IsNullOrEmpty(title))
|
||||||
|
{
|
||||||
|
hasVisibleWppWindow = true;
|
||||||
|
return false; // 找到一个就停止枚举
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
catch { }
|
||||||
catch { }
|
return true;
|
||||||
return true;
|
}, IntPtr.Zero);
|
||||||
}, IntPtr.Zero);
|
|
||||||
|
|
||||||
// 只要没有任何WPS相关可见窗口,就允许Kill
|
// 只要当前wpp进程没有可见窗口,就允许Kill
|
||||||
return hasVisibleWpsWindow;
|
return hasVisibleWppWindow;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
LogHelper.WriteLogToFile($"检查WPS前台窗口失败: {ex.ToString()}", LogHelper.LogType.Error);
|
LogHelper.WriteLogToFile($"检查WPP窗口失败: {ex.ToString()}", LogHelper.LogType.Error);
|
||||||
}
|
}
|
||||||
return false; // 出错时,默认允许Kill
|
return false; // 出错时,默认允许Kill
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user