Пример #1
0
 public ClipboardMonitor()
 {
     _messageListener = new MessageListener(() =>
     {
         var contents = ClipboardEx.GetContents();
         ClipboardChanged?.Invoke(this, new ClipboardChangedEventArgs(contents));
     });
 }
Пример #2
0
        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);
        }