public void Start()
 {
     Stream = Services.Keyboard.StreamText();
     Task.Run(async() =>
     {
         await foreach (var text in Stream.ToAsyncEnumerable())
         {
             if (text == TextTrigger)
             {
                 try
                 {
                     RunTests();
                 }
                 catch (Exception e)
                 {
                     Logger.Error("Test Execution Failed", e);
                 }
             }
         }
     });
 }
Esempio n. 2
0
 private void KeyboardStream(bool start = true)
 {
     if (start && _textStream == null)
     {
         _textStream = _services.Keyboard.StreamText();
         Task.Run(async() =>
         {
             while (await _textStream.MoveNext())
             {
                 Logger.Info("Keyboard Stream Received",
                             new Dictionary <string, object>()
                 {
                     ["text"] = _textStream.Current()
                 });
             }
         });
     }
     else if (start == false && _textStream != null)
     {
         _textStream?.Dispose();
         _textStream = null;
     }
 }
Esempio n. 3
0
        private void ClipboardStream()
        {
            _clipboardStream = _services.Clipboard.Stream();
            Logger.Info("Started Streaming Clipboard");
            Task.Run(async() =>
            {
                await foreach (var clipboardContent in _clipboardStream.ToAsyncEnumerable())
                {
                    try
                    {
                        Logger.Info($"Received Clipboard Update \"{clipboardContent}\"");
                        switch (clipboardContent)
                        {
                        case "fileinfo":
                            Logger.Info("Starting File Info");
                            try
                            {
                                var fileInfoStream = FileInfoStream();
                                fileInfoStream.ContinueWith(
                                    continuationAction: (task =>
                                {
                                    Logger.Error("Handled Exception", task.Exception);
                                }), TaskContinuationOptions.OnlyOnFaulted);
                            }
                            catch (Exception e)
                            {
                                Logger.Error("Exception Caught",
                                             new Dictionary <string, object>()
                                {
                                    { "error", e.ToString() }
                                });
                            }

                            break;

                        case "formnew":
                            FormStream();
                            Logger.Info("Starting Form Stream");
                            break;

                        case "keystart":
                            KeyboardStream();
                            break;

                        case "keystop":
                            KeyboardStream(false);
                            break;

                        case "windowtest":
                            WindowStream();
                            break;

                        case "listtest":
                            EmitListWhisper();
                            break;

                        default:
                            EmitWhisper(clipboardContent);
                            break;
                        }
                    }
                    catch (Exception e)
                    {
                        Logger.Error(e.ToString());
                    }
                }
            });
        }