public ClipboardMonitor() { _messageListener = new MessageListener(() => { var contents = ClipboardEx.GetContents(); ClipboardChanged?.Invoke(this, new ClipboardChangedEventArgs(contents)); }); }
static void Main(string[] args) { Win32Console.AttachConsole(); if (args.Contains("--listen")) { using var monitor = new ClipboardMonitor(); monitor.ClipboardChanged += (sender, eventArgs) => ConsoleEx.WriteJson(eventArgs.Contents); Application.Run(); return; } var contents = ClipboardEx.GetContents(); ConsoleEx.WriteJson(contents); }