fix: 复制按钮改用 SetDataObject + 兜底弹手动复制窗口(应对 UU远程 长占剪贴板)
用户反馈:网易UU远程 会长期占用剪贴板,前一次的 10×50ms 重试对长连接场景无用。 新方案采用三段降级: 1. Clipboard.SetDataObject(text, copy: true) — 用 IDataObject COM 接口(可能跟 OLE 路径分开排队),一次就成功 2. 失败回退 Clipboard.SetText + 10×50ms 重试(覆盖 RDP/杀软短暂持有) 3. 还失败(UU远程这种长连接)弹 CopyFallbackWindow:TextBox 预填文本,Loaded 时 Focus + SelectAll,用户自己 Ctrl+C 复制。窗口支持 Esc 关闭、点 [尝试复制] 再 retry 一次(对方可能刚好释放) 兜底窗口特性: - 模态(owner = MainWindow),居中 - 标题 "手动复制 — 剪贴板被其他程序占用",警告色文字 - 等宽字体 Consolas / Cascadia Code 显示多行文本 - 提示栏 "全选 Ctrl+A · 复制 Ctrl+C · 关闭 Esc" - [尝试复制] 蓝色按钮(成功 1.5s 内显示 "已复制 ✓",失败 "还是不行,手动 Ctrl+C") - [关闭] 按钮 IsCancel=True,Esc 也关 实测 UU远程场景:点复制 → 剪贴板写入失败 → 自动弹兜底窗口 → 文本已全选 → Ctrl+C 完成。完全绕过 OLE clipboard 锁。
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
<Window x:Class="WindowsGotify.CopyFallbackWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="手动复制 — 剪贴板被其他程序占用"
|
||||
Width="560" Height="400"
|
||||
MinWidth="400" MinHeight="280"
|
||||
WindowStartupLocation="CenterOwner"
|
||||
Background="{DynamicResource WindowBackground}"
|
||||
Foreground="{DynamicResource PrimaryText}"
|
||||
ShowInTaskbar="False"
|
||||
ResizeMode="CanResizeWithGrip">
|
||||
<Grid Margin="16">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<StackPanel Grid.Row="0" Margin="0,0,0,12">
|
||||
<TextBlock Text="⚠ 剪贴板被其他程序占用(疑似 网易UU远程 / RDP / 杀软 等)"
|
||||
FontSize="13" FontWeight="Bold"
|
||||
Foreground="{DynamicResource PendingDot}" />
|
||||
<TextBlock Text="下面的文本已全选(浅蓝高亮),请按 Ctrl+C 复制,然后按 Esc 或点 [关闭] 退出此窗口。"
|
||||
Foreground="{DynamicResource SecondaryText}"
|
||||
FontSize="11" Margin="0,4,0,0"
|
||||
TextWrapping="Wrap" />
|
||||
</StackPanel>
|
||||
|
||||
<TextBox Grid.Row="1" x:Name="ContentTextBox"
|
||||
IsReadOnly="True"
|
||||
IsReadOnlyCaretVisible="True"
|
||||
AcceptsReturn="True"
|
||||
TextWrapping="Wrap"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
HorizontalScrollBarVisibility="Auto"
|
||||
FontFamily="Consolas, Cascadia Code, Courier New"
|
||||
FontSize="12"
|
||||
Background="{DynamicResource CardAltBackground}"
|
||||
Foreground="{DynamicResource PrimaryText}"
|
||||
BorderBrush="{DynamicResource BorderColor}"
|
||||
SelectionBrush="{DynamicResource AccentBrush}" />
|
||||
|
||||
<TextBlock Grid.Row="2"
|
||||
x:Name="ShortcutsHint"
|
||||
Text="提示:全选 Ctrl+A · 复制 Ctrl+C · 关闭 Esc"
|
||||
FontSize="10"
|
||||
Foreground="{DynamicResource MutedText}"
|
||||
Margin="0,8,0,0" />
|
||||
|
||||
<StackPanel Grid.Row="3" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,12,0,0">
|
||||
<Button x:Name="CopyButton" Content="尝试复制" Width="90" Height="30" Margin="0,0,8,0"
|
||||
Click="CopyButton_Click"
|
||||
Background="{DynamicResource AccentBrush}"
|
||||
Foreground="{DynamicResource AccentText}" BorderThickness="0" />
|
||||
<Button x:Name="CloseButton" Content="关闭" Width="80" Height="30"
|
||||
Click="CloseButton_Click"
|
||||
IsCancel="True" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Window>
|
||||
Reference in New Issue
Block a user