huiyadanli / PasteEx

:clipboard: Paste As File 把剪贴板的内容直接粘贴为文件
GNU General Public License v3.0
1.31k stars 115 forks source link

添加自动保存限制图片大小的选项 #92

Open char-46 opened 8 months ago

char-46 commented 8 months ago

在开启监听模式自动保存的情况下,处理一些大图片时可能会向剪贴板内写入较大文件。此时 PasteEx 可能会出现异常并会向磁盘将文件写出。希望增加超出一定大小的图片不自动写出到文件的选项。

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.Runtime.InteropServices.ExternalException (0x800401D0): Requested Clipboard operation did not succeed.
   at System.Windows.Forms.Clipboard.ThrowIfFailed(Int32 hr)
   at System.Windows.Forms.Clipboard.SetDataObject(Object data, Boolean copy, Int32 retryTimes, Int32 retryDelay)
   at PasteEx.Core.ModeController.AppendFileToClipboard(String filePath)
   at PasteEx.Core.ModeController.ClipboardMonitor_OnClipboardChange(Object sender)
   at PasteEx.Core.ClipboardMonitor.OnClipboardChangeEvent(Object sender)
   at PasteEx.Core.ClipboardMonitor.ClipboardWatcher.ClipChanged(Object processId)
   at PasteEx.Core.ClipboardMonitor.ClipboardWatcher.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

************** Loaded Assemblies **************
mscorlib
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.9181.0 built by: NET481REL1LAST_C
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
PasteEx
    Assembly Version: 1.1.9.1
    Win32 Version: 1.1.9.1
    CodeBase: file:///E:/tools/PasteEx/PasteEx.exe
----------------------------------------
System.Windows.Forms
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.9181.0 built by: NET481REL1LAST_C
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.9172.0 built by: NET481REL1LAST_C
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.9032.0 built by: NET481REL1
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.9032.0 built by: NET481REL1
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Core
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.9200.0 built by: NET481REL1LAST_C
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System.Xml
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.9032.0 built by: NET481REL1
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Web.Extensions
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.9191.0
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Web.Extensions/v4.0_4.0.0.0__31bf3856ad364e35/System.Web.Extensions.dll
----------------------------------------
System.Management
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.9032.0 built by: NET481REL1
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Management/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Management.dll
----------------------------------------
PasteEx.resources
    Assembly Version: 1.1.9.1
    Win32 Version: 1.1.9.1
    CodeBase: file:///E:/tools/PasteEx/Language/zh-CN/PasteEx.resources.DLL
----------------------------------------
Windows.ApplicationModel
    Assembly Version: 255.255.255.255
    Win32 Version: 10.0.10011.16384
    CodeBase: file:///C:/WINDOWS/SysNative/WinMetadata/Windows.ApplicationModel.winmd
----------------------------------------
System.Runtime
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.9032.0
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Runtime/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Runtime.dll
----------------------------------------
Windows.Foundation
    Assembly Version: 255.255.255.255
    Win32 Version: 10.0.10011.16384
    CodeBase: file:///C:/WINDOWS/SysNative/WinMetadata/Windows.Foundation.winmd
----------------------------------------
Windows.Security
    Assembly Version: 255.255.255.255
    Win32 Version: 10.0.10011.16384
    CodeBase: file:///C:/WINDOWS/SysNative/WinMetadata/Windows.Security.winmd
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.
huiyadanli commented 8 months ago

这个报错一般是有两个剪切板程序同时在操作剪切板造成的。文件较大的时候操作速度慢所以你能够稳定复现这个问题。

首先应该找到这个监听并写入剪切板的程序(冲突程序),然后将 PasteEx 与其互相加入对方的黑名单中。

char-46 commented 8 months ago

另一个程序是 paint.net,在复制图片之后通过读取剪贴板中图片的大小新建画布。简单加入黑名单或许不可行,很多时候还是需要用到 PasteEx。

这个问题其实不是主要的……无非我点一下确认;想提的问题是保存大文件的时候会长时间占用磁盘或者向磁盘写入很多数据,是否可以设置一个自动保存的文件大小的上限。如超出 128MiB 的文件不保存等。