Example #1
0
        public async Task Execute(string command, bool submit)
        {
            if (string.IsNullOrEmpty(command))
            {
                return;
            }

            string clipboardValue = null;

            if (settings.RetainClipboard)
            {
                clipboardValue = await clipboard.GetText();
            }

            if (command.Contains(Token_Me_CharacterName))
            {
                // This operation is only valid if the user has added their character name to the settings file.
                if (string.IsNullOrEmpty(settings.Character_Name))
                {
                    logger.LogWarning(@"This command requires a ""CharacterName"" to be specified in the settings menu.");
                    return;
                }

                command = command.Replace(Token_Me_CharacterName, settings.Character_Name);
            }

            if (command.Contains(Token_LastWhisper_CharacterName))
            {
                var characterName = await mediator.Send(new GetLatestWhisperCharacterNameQuery());

                if (string.IsNullOrEmpty(characterName))
                {
                    logger.LogWarning(@"No last whisper was found in the log file.");
                    return;
                }

                command = command.Replace(Token_LastWhisper_CharacterName, characterName);
            }

            await clipboard.SetText(command);

            if (submit)
            {
                keyboard.PressKey("Enter", "Ctrl+A", "Paste", "Enter", "Enter", "Up", "Up", "Esc");
            }
            else
            {
                keyboard.PressKey("Enter", "Ctrl+A", "Paste");
            }

            if (settings.RetainClipboard)
            {
                await Task.Delay(100);

                await clipboard.SetText(clipboardValue);
            }
        }
Example #2
0
        public async Task <string> Copy()
        {
            var clipboardText = string.Empty;

            if (settings.RetainClipboard)
            {
                clipboardText = await TextCopy.ClipboardService.GetTextAsync();

                if (clipboardText == null)
                {
                    clipboardText = string.Empty;
                }
            }

            await SetText(string.Empty);

            keyboard.PressKey("Copy");

            await Task.Delay(100);

            // Retrieve clipboard.
            var result = await TextCopy.ClipboardService.GetTextAsync();

            if (settings.RetainClipboard)
            {
                await Task.Delay(100);

                await TextCopy.ClipboardService.SetTextAsync(clipboardText);
            }

            return(result);
        }
        public async Task Execute()
        {
            var text = await clipboardProvider.Copy();

            var item = await mediator.Send(new ParseItemCommand(text));

            if (item != null)
            {
                await clipboardProvider.SetText(item.Original.Name);

                keyboard.PressKey("Ctrl+F", "Ctrl+A", "Paste", "Enter");
            }
            else
            {
                // If we are not hovering over an item, we still want to put the focus in the search bar inside the game.
                keyboard.PressKey("Ctrl+F");
            }
        }
Example #4
0
        private Action GetKeybindAction <THandler>(string accelerator, string key)
            where THandler : IKeybindHandler
        {
            return(() =>
            {
                ElectronNET.API.Electron.GlobalShortcut.Unregister(accelerator);
                Thread.Sleep(1);

                var handler = serviceProvider.GetService <THandler>();
                if (handler.IsValid())
                {
                    Task.Run(async() =>
                    {
                        await handler.Execute();
                        ElectronNET.API.Electron.GlobalShortcut.Register(accelerator, GetKeybindAction <THandler>(accelerator, key));
                    });
                }
                else
                {
                    keyboardProvider.PressKey(key);
                    ElectronNET.API.Electron.GlobalShortcut.Register(accelerator, GetKeybindAction <THandler>(accelerator, key));
                }
            });
        }
 public Task Execute()
 {
     keyboard.PressKey("Left");
     return(Task.CompletedTask);
 }