// event. Click sur le boutton 'Intégrer' private void EmbedBtn_Click(object sender, EventArgs e) { if (GameWindowComboBox.Items.Count > 0) { BotName = GameWindowComboBox.SelectedValue.ToString(); GameProcess = Game.getProcessByWindowTitle(BotName); if (GameProcess != null) { // suppression du control de choix de la fenêtre du jeu GamePanel.Controls.Remove(SelectWindowGroupBox); // intégration du jeu dans le bot EmbedWindow.SetParent(GameProcess.MainWindowHandle, GamePanel.Handle); EmbedWindow.MoveWindow(GameProcess.MainWindowHandle, -Game.BorderPoint.X, -Game.BorderPoint.Y, GamePanel.Width + Game.BorderSize.Width, GamePanel.Height + Game.BorderSize.Height, true); // changement du nom de la fenêtre/bot this.Text = BotName; // Désactivation du panel du jeu GamePanel.Enabled = false; // Activation des outils du trajet TrajetActionsImageGroupBox.Enabled = true; // Activation de la possibilité de simuler les mouvements d'un trajet SimulateMoveCheckBox.Enabled = true; // Activation de la possibilité de capturer l'écran du jeu ScreenshotToolStripMenuItem.Enabled = true; // Activation de la possibilité de vérouiller/dévérouiller l'interface du jeu LockUnlockGameToolStripMenuItem.Enabled = true; // Activation de la possibilité de la configuration des ressources/IA combat AddResourceBtn.Enabled = true; AddSpellBtn.Enabled = true; AddTargetBtn.Enabled = true; // on permet aux threads d'accéder aux controls du BotForm BotForm.CheckForIllegalCrossThreadCalls = false; // initialisation du Log du bot Log = new Log(LogRichTextBox, DebugRichTextBox, BotName); Log.Debug("Game Window : " + BotName); Log.Debug("Game Panel Resolution : " + GamePanel.Width + "x" + GamePanel.Height); // Adaptation des coordonnées des mouvements au Game Panel Core.Move.FitMovesTo(GamePanel.Width, GamePanel.Height); Log.Debug("Move UP Point : " + Core.Move.UP.X + "x" + Core.Move.UP.Y); Log.Debug("Move RIGHT Point : " + Core.Move.RIGHT.X + "x" + Core.Move.RIGHT.Y); Log.Debug("Move DOWN Point : " + Core.Move.DOWN.X + "x" + Core.Move.DOWN.Y); Log.Debug("Move LEFT Point : " + Core.Move.LEFT.X + "x" + Core.Move.LEFT.Y); // Adaptation des coordonnées des pixels à vérifier de la Map au Game Panel Map.FitPixelsToCheckTo(GamePanel.Width, GamePanel.Height); int i = 0; foreach (Point pixel in Map.PixelsToCheck) { Log.Debug("Map Pixel To Check [" + ++i + "] ( X: " + pixel.X + " Y: " + pixel.Y + ")"); } } } }
// [Menu] event. Click on 'ScreenshotToolStripMenuItem' private void ScreenshotToolStripMenuItem_Click(object sender, EventArgs e) { SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.InitialDirectory = App.CurrentPath; saveFileDialog1.RestoreDirectory = true; saveFileDialog1.FileName = "Screenshot_" + DateTime.Now.ToString("dd-MM-yy_HH-mm-ss"); saveFileDialog1.Title = "Capturer une image"; saveFileDialog1.DefaultExt = "bmp"; saveFileDialog1.Filter = "Image BMP (*.bmp)|*.bmp"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { // capture de l'image et sauvegarde dans le fichier spécifié Bitmap image = EmbedWindow.GetWindowImage(GameProcess.MainWindowHandle); image.Save(saveFileDialog1.FileName); MessageBox.Show("Image Capturée !", App.Name, MessageBoxButtons.OK, MessageBoxIcon.Information); } }
// event. FormClosing du formulaire private void BotForm_FormClosing(object sender, FormClosingEventArgs e) { if (GameProcess == null || MessageBox.Show("Voulez-vous vraiment quitter le bot ?", App.Name, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { if (GameProcess != null) { // Arret du thread du bot s'il a été démarré if (RunBotBtn.Text != "Démarrer") { Bot.Stop(); } // remise/réaffichage du jeu sur le bureau EmbedWindow.SetParent(GameProcess.MainWindowHandle, IntPtr.Zero); // IntPtr.Zero == NULL (si NULL le parent sera le bureau/desktop) EmbedWindow.MoveWindow(GameProcess.MainWindowHandle, Game.DefaultRect.X, Game.DefaultRect.Y, Game.DefaultRect.Width, Game.DefaultRect.Height, true); } } else { e.Cancel = true; } }
// GetPod() : récupère le pod en pourcentage et fait avancé la progressbar public void GetPod() { Log.Title(Log.Level.Debug, "GetPod"); try { // Click sur l'inventaire pour l'ouvrir FakeClick.ClickOnPoint(GameHandle, Settings.InventoryPosition); Wait(); // Nouvelle Image de la Map Bitmap MapImage = EmbedWindow.GetWindowImage(GameHandle); // MapBitmap LockBitmap MapBitmap = new LockBitmap(MapImage); MapBitmap.LockBits(); Color?PodBarColor = null; int PodValue = 0; // Get PodValue for (int x = Pod.PodBarX; x < Pod.PodBarEndX; x++) { _pauseEvent.WaitOne(); if (_shutdownEvent.WaitOne(0)) { break; } if (PodBarColor == null) // on récupère la couleur dominente { PodBarColor = MapBitmap.GetPixel(x, Pod.PodBarY); } // si la couleur est toujours dominente on continue if (MapBitmap.GetPixel(x, Pod.PodBarY) == PodBarColor) { PodValue++; } else // si nn on s'arrete { break; } } MapBitmap.UnlockBits(); if (!_shutdownEvent.WaitOne(0)) // si le bot n'a pas été arrêté { // Set Pod PercentValue (%) Pod.PercentValue = (int)((float)((float)PodValue / Pod.PodBarWidth) * 100); Log.Debug("Pod PodValue: " + PodValue + " PercentValue: " + Pod.PercentValue + "%"); // Set Progressbar FillProcent PodProgressBar.BarFillProcent = Pod.PercentValue; // ReClick sur l'inventaire pour le fermer FakeClick.ClickOnPoint(GameHandle, Settings.InventoryPosition); Wait(); } } catch (Exception ex) { Log.Debug("Execption occured : " + ex.Message); } finally { Log.Divider(Log.Level.Debug); } }