add:issue #180
This commit is contained in:
@@ -164,31 +164,6 @@ namespace Ink_Canvas
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 调试:列出所有可见窗口
|
||||
/// </summary>
|
||||
public void DebugListAllWindows()
|
||||
{
|
||||
if (_interceptor == null)
|
||||
{
|
||||
LogHelper.WriteLogToFile("拦截器未初始化,无法进行调试", LogHelper.LogType.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
LogHelper.WriteLogToFile("开始调试扫描所有可见窗口...", LogHelper.LogType.Event);
|
||||
|
||||
// 直接调用扫描方法,在扫描过程中会输出调试信息
|
||||
_interceptor.ScanOnce();
|
||||
|
||||
LogHelper.WriteLogToFile("调试扫描完成,请查看日志文件获取详细信息", LogHelper.LogType.Event);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"调试列出窗口失败: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 恢复所有被拦截的窗口
|
||||
|
||||
@@ -212,8 +212,8 @@ namespace Ink_Canvas.Helpers
|
||||
{
|
||||
Type = InterceptType.SeewoWhiteboard5Floating,
|
||||
ProcessName = "EasiNote5",
|
||||
WindowTitlePattern = "",
|
||||
ClassNamePattern = "",
|
||||
WindowTitlePattern = "希沃白板",
|
||||
ClassNamePattern = "EasiNote5",
|
||||
IsEnabled = true,
|
||||
RequiresAdmin = false,
|
||||
Description = "希沃白板5 桌面悬浮窗"
|
||||
@@ -351,7 +351,7 @@ namespace Ink_Canvas.Helpers
|
||||
Description = "希沃桌面 侧栏悬浮窗"
|
||||
};
|
||||
|
||||
// 测试规则 - 拦截所有小窗口
|
||||
// 拦截所有小窗口
|
||||
_interceptRules[InterceptType.SeewoWhiteboard3Floating] = new InterceptRule
|
||||
{
|
||||
Type = InterceptType.SeewoWhiteboard3Floating,
|
||||
@@ -360,7 +360,7 @@ namespace Ink_Canvas.Helpers
|
||||
ClassNamePattern = "",
|
||||
IsEnabled = false, // 默认关闭,需要手动开启
|
||||
RequiresAdmin = false,
|
||||
Description = "测试规则 - 拦截所有小窗口"
|
||||
Description = "拦截所有小窗口"
|
||||
};
|
||||
}
|
||||
|
||||
@@ -495,9 +495,6 @@ namespace Ink_Canvas.Helpers
|
||||
var windowInfo = GetWindowInfo(hWnd);
|
||||
if (windowInfo == null) return true;
|
||||
|
||||
// 输出调试信息到日志
|
||||
LogHelper.WriteLogToFile($"检测到窗口: '{windowInfo.WindowTitle}' | 进程: '{windowInfo.ProcessName}' | 类名: '{windowInfo.ClassName}'", LogHelper.LogType.Event);
|
||||
|
||||
// 检查窗口样式,过滤掉系统窗口和主窗口
|
||||
var exStyle = GetWindowLong(hWnd, GWL_EXSTYLE);
|
||||
var style = GetWindowLong(hWnd, -16); // GWL_STYLE
|
||||
@@ -505,7 +502,6 @@ namespace Ink_Canvas.Helpers
|
||||
// 跳过工具窗口
|
||||
if ((exStyle & WS_EX_TOOLWINDOW) != 0)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"跳过工具窗口: {windowInfo.WindowTitle}", LogHelper.LogType.Event);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -514,7 +510,6 @@ namespace Ink_Canvas.Helpers
|
||||
const uint WS_SYSMENU = 0x00080000;
|
||||
if ((style & WS_CAPTION) != 0 && (style & WS_SYSMENU) != 0)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"跳过主窗口: {windowInfo.WindowTitle}", LogHelper.LogType.Event);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -526,7 +521,6 @@ namespace Ink_Canvas.Helpers
|
||||
|
||||
if (width > 600 || height > 400)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"跳过大窗口 ({width}x{height}): {windowInfo.WindowTitle}", LogHelper.LogType.Event);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -537,7 +531,6 @@ namespace Ink_Canvas.Helpers
|
||||
|
||||
if (MatchesRule(windowInfo, rule))
|
||||
{
|
||||
LogHelper.WriteLogToFile($"匹配规则 '{rule.Description}',开始拦截窗口: {windowInfo.WindowTitle}", LogHelper.LogType.Event);
|
||||
InterceptWindow(hWnd, rule);
|
||||
break;
|
||||
}
|
||||
@@ -647,8 +640,6 @@ namespace Ink_Canvas.Helpers
|
||||
// 记录拦截的窗口
|
||||
_interceptedWindows[hWnd] = rule.Type;
|
||||
|
||||
LogHelper.WriteLogToFile($"成功拦截窗口: {GetWindowTitle(hWnd)}", LogHelper.LogType.Event);
|
||||
|
||||
// 触发事件
|
||||
WindowIntercepted?.Invoke(this, new WindowInterceptedEventArgs
|
||||
{
|
||||
|
||||
@@ -2964,30 +2964,10 @@
|
||||
|
||||
<!-- 控制按钮 -->
|
||||
<ui:SimpleStackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="0,8,0,8">
|
||||
<Button Name="BtnFloatingWindowInterceptorStart" Content="启动拦截"
|
||||
Padding="12,6" Margin="0,0,8,0" Click="BtnFloatingWindowInterceptorStart_Click"
|
||||
Background="#FF28A745" Foreground="White" BorderBrush="#FF1E7E34"
|
||||
FontFamily="Microsoft YaHei UI" FontSize="12" />
|
||||
<Button Name="BtnFloatingWindowInterceptorStop" Content="停止拦截"
|
||||
Padding="12,6" Margin="0,0,8,0" Click="BtnFloatingWindowInterceptorStop_Click"
|
||||
Background="#FFDC3545" Foreground="White" BorderBrush="#FFBD2130"
|
||||
FontFamily="Microsoft YaHei UI" FontSize="12" />
|
||||
<Button Name="BtnFloatingWindowInterceptorScan" Content="手动扫描"
|
||||
Padding="12,6" Margin="0,0,8,0" Click="BtnFloatingWindowInterceptorScan_Click"
|
||||
Background="#FF17A2B8" Foreground="White" BorderBrush="#FF138496"
|
||||
FontFamily="Microsoft YaHei UI" FontSize="12" />
|
||||
<Button Name="BtnFloatingWindowInterceptorRestore" Content="恢复所有窗口"
|
||||
Padding="12,6" Margin="0,0,8,0" Click="BtnFloatingWindowInterceptorRestore_Click"
|
||||
Background="#FF6C757D" Foreground="White" BorderBrush="#FF5A6268"
|
||||
FontFamily="Microsoft YaHei UI" FontSize="12" />
|
||||
<Button Name="BtnFloatingWindowInterceptorDebug" Content="调试列出窗口"
|
||||
Padding="12,6" Margin="0,0,8,0" Click="BtnFloatingWindowInterceptorDebug_Click"
|
||||
Background="#FF6F42C1" Foreground="White" BorderBrush="#FF5A2D91"
|
||||
FontFamily="Microsoft YaHei UI" FontSize="12" />
|
||||
<Button Name="BtnFloatingWindowInterceptorTest" Content="测试拦截"
|
||||
Padding="12,6" Click="BtnFloatingWindowInterceptorTest_Click"
|
||||
Background="#FFE83E8C" Foreground="White" BorderBrush="#FFC2185B"
|
||||
FontFamily="Microsoft YaHei UI" FontSize="12" />
|
||||
</ui:SimpleStackPanel>
|
||||
|
||||
<!-- 状态信息 -->
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Ink_Canvas.Helpers;
|
||||
using iNKORE.UI.WPF.Modern.Controls;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
@@ -79,17 +80,21 @@ namespace Ink_Canvas
|
||||
var isEnabled = Settings.Automation.FloatingWindowInterceptor.IsEnabled;
|
||||
FloatingWindowInterceptorGrid.Visibility = isEnabled ? Visibility.Visible : Visibility.Collapsed;
|
||||
|
||||
// 计算启用的规则数量
|
||||
var enabledRulesCount = Settings.Automation.FloatingWindowInterceptor.InterceptRules.Where(kvp => kvp.Value).Count();
|
||||
var totalRulesCount = Settings.Automation.FloatingWindowInterceptor.InterceptRules.Count;
|
||||
|
||||
// 更新状态文本
|
||||
if (_floatingWindowInterceptorManager != null)
|
||||
{
|
||||
var stats = _floatingWindowInterceptorManager.GetStatistics();
|
||||
TextBlockFloatingWindowInterceptorStatus.Text = stats.IsRunning
|
||||
? $"拦截器运行中 - 已启用 {stats.EnabledRules}/{stats.TotalRules} 个规则"
|
||||
: "拦截器未启动";
|
||||
? $"拦截器运行中 - 已启用 {enabledRulesCount}/{totalRulesCount} 个规则"
|
||||
: $"拦截器未启动 - 已启用 {enabledRulesCount}/{totalRulesCount} 个规则";
|
||||
}
|
||||
else
|
||||
{
|
||||
TextBlockFloatingWindowInterceptorStatus.Text = "拦截器未初始化";
|
||||
TextBlockFloatingWindowInterceptorStatus.Text = $"拦截器未初始化 - 已启用 {enabledRulesCount}/{totalRulesCount} 个规则";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -308,6 +313,9 @@ namespace Ink_Canvas
|
||||
Settings.Automation.FloatingWindowInterceptor.InterceptRules[ruleName] = enabled;
|
||||
}
|
||||
|
||||
// 更新UI显示
|
||||
UpdateFloatingWindowInterceptorUI();
|
||||
|
||||
SaveSettingsToFile();
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -316,62 +324,6 @@ namespace Ink_Canvas
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 启动拦截按钮点击
|
||||
/// </summary>
|
||||
private void BtnFloatingWindowInterceptorStart_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_floatingWindowInterceptorManager != null)
|
||||
{
|
||||
_floatingWindowInterceptorManager.Start();
|
||||
UpdateFloatingWindowInterceptorUI();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"启动悬浮窗拦截失败: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 停止拦截按钮点击
|
||||
/// </summary>
|
||||
private void BtnFloatingWindowInterceptorStop_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_floatingWindowInterceptorManager != null)
|
||||
{
|
||||
_floatingWindowInterceptorManager.Stop();
|
||||
UpdateFloatingWindowInterceptorUI();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"停止悬浮窗拦截失败: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 手动扫描按钮点击
|
||||
/// </summary>
|
||||
private void BtnFloatingWindowInterceptorScan_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_floatingWindowInterceptorManager != null)
|
||||
{
|
||||
_floatingWindowInterceptorManager.ScanOnce();
|
||||
UpdateFloatingWindowInterceptorUI();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"手动扫描失败: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 恢复所有窗口按钮点击
|
||||
@@ -391,73 +343,6 @@ namespace Ink_Canvas
|
||||
LogHelper.WriteLogToFile($"恢复所有窗口失败: {ex.Message}", LogHelper.LogType.Error);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 调试列出窗口按钮点击
|
||||
/// </summary>
|
||||
private void BtnFloatingWindowInterceptorDebug_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_floatingWindowInterceptorManager != null)
|
||||
{
|
||||
// 更新状态显示
|
||||
TextBlockFloatingWindowInterceptorStatus.Text = "正在调试扫描窗口...";
|
||||
|
||||
_floatingWindowInterceptorManager.DebugListAllWindows();
|
||||
|
||||
// 更新状态显示
|
||||
TextBlockFloatingWindowInterceptorStatus.Text = "调试扫描完成,请查看日志文件";
|
||||
|
||||
LogHelper.WriteLogToFile("用户点击了调试列出窗口按钮", LogHelper.LogType.Event);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogToFile("拦截器管理器未初始化", LogHelper.LogType.Warning);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"调试列出窗口失败: {ex.Message}", LogHelper.LogType.Error);
|
||||
TextBlockFloatingWindowInterceptorStatus.Text = "调试扫描失败";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 测试拦截按钮点击
|
||||
/// </summary>
|
||||
private void BtnFloatingWindowInterceptorTest_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (_floatingWindowInterceptorManager != null)
|
||||
{
|
||||
// 更新状态显示
|
||||
TextBlockFloatingWindowInterceptorStatus.Text = "正在测试拦截功能...";
|
||||
|
||||
// 启用测试规则
|
||||
_floatingWindowInterceptorManager.SetInterceptRule(FloatingWindowInterceptor.InterceptType.SeewoWhiteboard3Floating, true);
|
||||
|
||||
// 执行一次扫描
|
||||
_floatingWindowInterceptorManager.ScanOnce();
|
||||
|
||||
// 更新状态显示
|
||||
TextBlockFloatingWindowInterceptorStatus.Text = "测试拦截完成,请查看日志文件";
|
||||
|
||||
LogHelper.WriteLogToFile("用户点击了测试拦截按钮", LogHelper.LogType.Event);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogHelper.WriteLogToFile("拦截器管理器未初始化", LogHelper.LogType.Warning);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.WriteLogToFile($"测试拦截失败: {ex.Message}", LogHelper.LogType.Error);
|
||||
TextBlockFloatingWindowInterceptorStatus.Text = "测试拦截失败";
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user