예제 #1
0
        public async Task FindNewSessionAsync()
        {
            IUserMessage response;
            EmbedBuilder initialBuilder;


            initialBuilder = EmbedHelper.GetDefaultEmbed(Context);
            initialBuilder.AddField(":mag: Finding new session", "Please wait...");

            response = await ReplyAsync("", embed : initialBuilder.Build());

            try {
                EmbedBuilder    embed;
                IntPtr          windowHandle;
                ProcessProvider provider;


                embed    = EmbedHelper.GetDefaultEmbed(Context);
                provider = new ProcessProvider();

                embed.AddField(":robot: Stopping bot process", "Please wait...");

                _screenshotProvider.Stop();

                embed.AddField(":white_check_mark: Success", "The bot process has been stopped.");
                embed.AddField(":mag: Finding new session", "Please wait...");

                await response.ModifyAsync(msg => { msg.Embed = embed.Build(); msg.Content = ""; });

                windowHandle = provider.GetGrandTheftAutoProcessPointer();

                User32.GetWindowThreadProcessId(windowHandle, out uint processID);

                if (processID != 0)
                {
                    Process process;


                    process = Process.GetProcessById((int)processID);

                    process.Suspend();
                    Thread.Sleep(8000);
                    process.Resume();
                }


                embed.AddField(":white_check_mark: Success", "A new session has been found.");
                embed.AddField(":robot: Starting bot script", "Please wait");

                await response.ModifyAsync(msg => { msg.Embed = embed.Build(); msg.Content = ""; });

                _screenshotProvider.Start();

                embed.AddField(":white_check_mark: Success", "Bot script started ");

                await response.ModifyAsync(msg => { msg.Embed = embed.Build(); msg.Content = ""; });
            } catch (Exception e) {
                await response.ModifyAsync(msg => msg = ErrorHandler.GetDefaultErrorMessageEmbed(e, msg, Context.Message));
            }
        }
예제 #2
0
        public async Task EnterGTAOnlineAsync()
        {
            IUserMessage    response;
            EmbedBuilder    initialBuilder;
            ProcessProvider provider;


            initialBuilder = EmbedHelper.GetDefaultEmbed(Context);
            initialBuilder.AddField(":keyboard: Pressing buttons", "Please wait...");
            provider = new ProcessProvider();

            response = await ReplyAsync("", embed : initialBuilder.Build());

            Console.WriteLine(AppDomain.CurrentDomain.BaseDirectory);

            try {
                EmbedBuilder     embed;
                string           path;
                Process          process;
                ProcessStartInfo startInfo;
                IntPtr           windowHandle;


                path  = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Resources");
                embed = EmbedHelper.GetDefaultEmbed(Context);

                startInfo          = new ProcessStartInfo();
                startInfo.FileName = $"{path}\\enterOnline.exe";

                process           = new Process();
                process.StartInfo = startInfo;

                windowHandle = provider.GetGrandTheftAutoProcessPointer();

                User32.SetForegroundWindow(windowHandle);

                process.Start();

                embed.AddField("Buttons Pressed", "IDK what to put here, things are happening I guess?");

                await response.ModifyAsync(msg => { msg.Embed = embed.Build(); msg.Content = ""; });
            } catch (Exception e) {
                await response.ModifyAsync(msg => msg = ErrorHandler.GetDefaultErrorMessageEmbed(e, msg, Context.Message));
            }
        }
예제 #3
0
        public async Task BringWindowToForegroundAsync()
        {
            IUserMessage response;
            EmbedBuilder initialBuilder;


            initialBuilder = EmbedHelper.GetDefaultEmbed(Context);
            initialBuilder.AddField("Bringing GTA Process to foreground", "Please wait...");

            response = await ReplyAsync("", embed : initialBuilder.Build());

            try {
                IntPtr          windowHandle;
                ProcessProvider provider;
                EmbedBuilder    embed;
                Stopwatch       watch;


                watch = new Stopwatch();
                watch.Start();

                embed    = EmbedHelper.GetDefaultEmbed(Context);
                provider = new ProcessProvider();

                windowHandle = provider.GetGrandTheftAutoProcessPointer();

                User32.SetForegroundWindow(windowHandle);
                watch.Stop();

                embed.AddField(":white_check_mark: Success", "GTA Process is in foreground.");
                embed.AddField(":alarm_clock: Time taken to complete action", watch.Elapsed.ToString("mm'm 'ss's 'fff'ms'"));

                await response.ModifyAsync(msg => { msg.Embed = embed.Build(); msg.Content = ""; });
            } catch (Exception e) {
                await response.ModifyAsync(msg => msg = ErrorHandler.GetDefaultErrorMessageEmbed(e, msg, Context.Message));
            }
        }