static void Main(string[] args) { Logger.OnStartup(); Logger.Write("Loading LeagueBot..."); Configuration.LoadConfig(); PatternsManager.Initialize(); PixelCache.Initialize(); TextRecognition.Initialize(); try { LeagueManager.ApplySettings(); } catch { Logger.Write("Unable to set league of legends settings. (Probably due to permission restrictions.)", MessageState.WARNING); } HandleCommand(); Console.Read(); }
public void Setup(string fileName) { Repository = new Repository(); Repository.Load(); _window = Substitute.For <IEmulatorWindow>(); var settings = Substitute.For <ISettings>(); var recognition = new TextRecognition(); var loggerFactory = Substitute.For <ILoggerFactory>(); _videoProvider = Substitute.For <IVideoProvider>(); Game = new GameImpl(_window, _videoProvider, Repository, loggerFactory, recognition, settings); #if DEBUG Settings.SaveImages = true; Settings.SaveRawImages = true; #endif using var bitmap = new Bitmap(fileName); _window.Width.Returns(bitmap.Width); _window.Height.Returns(bitmap.Height); _window.GrabScreen(Arg.Any <int>(), Arg.Any <int>(), Arg.Any <int>(), Arg.Any <int>()) .Returns(info => { using var bitmapLocal = new Bitmap(fileName); return(bitmapLocal.Crop(info.ArgAt <int>(0), info.ArgAt <int>(1), info.ArgAt <int>(2), info.ArgAt <int>(3))); }); _videoProvider.GetCurrentFrame().Returns(info => bitmap); }
public void leftClickText(string text) { if (TextRecognition.TextExists(text)) { Point coords = TextRecognition.TextCoords(text); Mouse.Move(coords.X, coords.Y); Mouse.PressButton(Mouse.MouseKeys.Left, 150); } }
public void waitForText2(string processName, string text) { bool exists = TextRecognition.TextExists2(processName, text); while (!exists) { Thread.Sleep(1000); exists = TextRecognition.TextExists2(processName, text); } }
public void waitForText(string text) { bool exists = TextRecognition.TextExists(text); while (!exists) { exists = TextRecognition.TextExists(text); Thread.Sleep(1000); } }
public static void WaitForText(int x, int y, int width, int heigth, string text) { Rectangle rect = new Rectangle(x, y, width, heigth); bool exists = TextRecognition.TextExists2(rect, text); while (!exists) { BotHelper.Wait(1000); exists = TextRecognition.TextExists2(rect, text); } }
internal static int GetTextFromImage(int x, int y, int width, int heigth) { Rectangle rect; try { rect = new Rectangle(x, y, width, heigth); } catch { return(0); } return(TextRecognition.GetTextValue(rect)); }
public static bool TextExists(int x, int y, int width, int heigth, string text) { bool exist; try { exist = TextRecognition.TextExists2(new Rectangle(x, y, width, heigth), text); } catch { exist = false; } return(exist); }
public static bool TextExists(int x, int y, int width, int heigth, string text) { return(TextRecognition.TextExists2(new Rectangle(x, y, width, heigth), text)); }
private void ConfigureSerivces(ServiceCollection serviceCollection) { var uiLogger = new CustomUiLoggerProvider(); ILoggerFactory loggerFactory = LoggerFactory.Create( (builder) => { builder .AddProvider(new CustomConsoleProvider()) .AddProvider(new CustomTraceProvider()) .AddProvider(uiLogger) .SetMinimumLevel(LogLevel.Debug); }); Directory.CreateDirectory("Settings"); var path = Path.Combine("Settings", "config.json"); var setupDefaultConfig = !File.Exists(path); var settings = new ConfigurationBuilder <ISettings>() .UseJsonFile(path). Build(); if (setupDefaultConfig) { SetupDefaultConfiguration(settings); } else { EnsureValidValues(settings); } serviceCollection.AddSingleton(settings); var recognition = new TextRecognition(); var executioner = new TaskExecutioner(loggerFactory.CreateLogger <TaskExecutioner>()); var window = SetupWindow(settings, loggerFactory, recognition); var videoProvider = new VideoProvider(window, settings.VideoCapture.FrameRate); serviceCollection.AddSingleton <IVideoProvider>(videoProvider); serviceCollection.AddSingleton <IVideoCapture, VideoCapture>(); var repository = new Repository(); repository.Load(); var game = new GameImpl(window, videoProvider, repository, loggerFactory, recognition, settings); var overlay = new ImGuiOverlay(game, window, repository); if (settings.EnableOverlay) { //circular dependency. find better solution. game.Overlay = overlay; overlay.Setup(); } serviceCollection.AddSingleton <IEmulatorOverlay>(overlay); var picker = new AreaPicker(window, overlay); serviceCollection.AddSingleton <ITaskExecutioner>(executioner); serviceCollection.AddSingleton <ITaskQueue>(executioner); serviceCollection.AddSingleton <IGame>(game); serviceCollection.AddSingleton <IAreaPicker>(picker); serviceCollection.AddSingleton <IUiRepository>(repository); serviceCollection.AddSingleton(window); serviceCollection.AddSingleton <IUiLogger>(uiLogger); ViewModelLocator.ConfigureServices(serviceCollection); if (settings.EnableOverlay) { Dispatcher.BeginInvoke(async() => await UpdateOverlay(overlay)); } }
public bool textExists(string processName, string text) { return(TextRecognition.TextExists2(processName, text)); }