#ifdef 12 Posted November 20 Is there any way/API to get a clipboard history (Win + V)? Share this post Link to post
Anders Melander 1815 Posted November 20 AFAIK there's no such thing in Windows as a clipboard history. Applications, and libraries (.NET, UWP, etc.), that offer a clipboard history does so by monitoring the clipboard and making local copies of the content when stuff is copied onto the clipboard. This is why Windows' own clipboard history (WinKey+V) is always empty when you first invoke it. It needs to run in the background before it can collect data from the clipboard; Windows itself doesn't maintain a history. This is also why it is very limited what data is stored in the clipboard history; The clipboard history application doesn't support a lot of formats (mostly text and bitmaps) and some data is only valid at the time when they were copied and require that the data source is live when the data is pasted. You can use the drop target analyzer application from the Drag and Drop Component Suite to see the impact, in terms of requests made to the data source, of running the Windows clipboard history in the background. The drop source analyzer can be used to examine the difference between data copied directly from the clipboard and data that has been through the clipboard history. Share this post Link to post
Roger Cigol 107 Posted November 20 1 hour ago, Anders Melander said: This is why Windows' own clipboard history (WinKey+V) is always empty when you first invoke it Not sure about this. It's empty when you first start windows. But as soon as you start using the clip board with any application Windows does maintain a history and WinKey+V does allow you to choose. However I don't know a way of accessing these values programatically. But that doesn't mean there isn't a way..... Share this post Link to post
Anders Melander 1815 Posted November 20 17 minutes ago, Roger Cigol said: It's empty when you first start windows. But as soon as you start using the clip board with any application Windows does maintain a history On my system (Windows 10) the history only contains data copied after first Win+V. Win+V starts the "Clipboard User Service" (svchost.exe -k ClipboardSvcGroup -p). The service is set to manual start. Maybe it's set to auto start on your system? Anyway, the history is not part of the clipboard system. It's just an application on top of it, no different from one that you could write yourself. Trying to access the clipboard history data when there is no public API is IMO a waste of time when you can just replicate what it does. It's not that hard. Share this post Link to post
Rollo62 538 Posted November 21 14 hours ago, Anders Melander said: On my system (Windows 10) the history only contains data copied after first Win+V. Win+V starts the "Clipboard User Service" (svchost.exe -k ClipboardSvcGroup -p). The service is set to manual start. Maybe it's set to auto start on your system? Anyway, the history is not part of the clipboard system. It's just an application on top of it, no different from one that you could write yourself. Trying to access the clipboard history data when there is no public API is IMO a waste of time when you can just replicate what it does. It's not that hard. It works on my Win 10 and Win 11 systems, although I confess that I never used this before. AFAIK there are methods to access the ClipboardHistory under Windows, which are implemented in WinRT only. Never used that either, mainly because the WinRT requirement. Share this post Link to post
Anders Melander 1815 Posted November 21 2 minutes ago, Rollo62 said: AFAIK there are methods to access the ClipboardHistory under Windows, which are implemented in WinRT only. Again: Not a part of the clipboard system; A layer on top of it. It is not a single global history that is managed somewhere. It is just individual services that maintain their own history. So not "the clipboard" history but "a clipboard" history. Share this post Link to post
Brandon Staggs 283 Posted November 21 A clipboard history is a convenient way to see lots of passwords in plaintext. Who wouldn't love that. 3 1 Share this post Link to post
Remy Lebeau 1429 Posted November 21 (edited) Enumerating Windows clipboard history in C++/WinRT and C# Enumerating Windows clipboard history in PowerShell 9 hours ago, Anders Melander said: So not "the clipboard" history but "a clipboard" history. But, the way Microsoft describes this API, they make it sound like it is "the clipboard" history. Edited November 21 by Remy Lebeau 1 Share this post Link to post
Anders Melander 1815 Posted November 21 1 hour ago, Remy Lebeau said: But, the way Microsoft describes this API, they make it sound like it is "the clipboard" history. Sure but the fact that it's only available via WinRT sort of confirms that it isn't, doesn't it? Share this post Link to post
DelphiUdIT 187 Posted November 21 On 11/20/2024 at 1:36 PM, #ifdef said: Is there any way/API to get a clipboard history (Win + V)? Catch the clipboard is really simply, why don't you do it ? Using the JvClipboardMonitor, you can "ear" all "copy" actions, you can also choose what you are cacthing (look at source of JvClipboardMonitor and Microsoft docs). That example is simple, no control about the "paste". That catch also the administrator level "copy" and all copy / paste password .... like @Brandon Staggs said. unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, JvComponentBase, JvClipboardMonitor, Vcl.StdCtrls; type TForm1 = class(TForm) JvClipboardMonitor1: TJvClipboardMonitor; Memo1: TMemo; procedure JvClipboardMonitor1Change(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.JvClipboardMonitor1Change(Sender: TObject); begin Memo1.PasteFromClipboard; Memo1.Lines.Add(#10#13); end; end. Share this post Link to post