private void Window_Loaded(object sender, RoutedEventArgs e) { // Init GUI stuff // -------------- > InteropHelper = new WindowInteropHelper(this); PresentationSource presentationSource = PresentationSource.FromVisual(this); M11 = presentationSource.CompositionTarget.TransformToDevice.M11; M22 = presentationSource.CompositionTarget.TransformToDevice.M22; comboboxStateOverride.Items.Add(BotState.Idle); comboboxStateOverride.Items.Add(BotState.Attacking); comboboxStateOverride.Items.Add(BotState.Grinding); comboboxStateOverride.Items.Add(BotState.Job); comboboxStateOverride.Items.Add(BotState.Questing); comboboxStateOverride.SelectedIndex = 0; labelPID.Content = $"PID: {Environment.ProcessId}"; if (Config.Autopilot) { buttonToggleAutopilot.Foreground = CurrentTickTimeGoodBrush; } if (!Directory.Exists(DataPath)) { Directory.CreateDirectory(DataPath); } // Init the bot // ------------ > AmeisenBot = new AmeisenBot(DataPath, Path.GetFileName(Path.GetDirectoryName(ConfigPath)), Config, InteropHelper.EnsureHandle()); AmeisenBot.WowInterface.ObjectManager.OnObjectUpdateComplete += OnObjectUpdateComplete; AmeisenBot.StateMachine.OnStateMachineStateChanged += OnStateMachineStateChange; AmeisenBot.StateMachine.GetState <StateStartWow>().OnWoWStarted += MainWindow_OnWoWStarted; StateConfigWindows = new Dictionary <BotState, Window>() { { BotState.Grinding, new StateGrindingConfigWindow(AmeisenBot, AmeisenBot.Config) }, { BotState.Job, new StateJobConfigWindow(AmeisenBot, AmeisenBot.Config) }, { BotState.Questing, new StateQuestingConfigWindow(AmeisenBot, AmeisenBot.Config) }, }; AmeisenBot.Start(); }
private void Window_Loaded(object sender, RoutedEventArgs e) { labelPID.Content = $"PID: {Process.GetCurrentProcess().Id}"; if (Config != null) { string playername = Path.GetFileName(Path.GetDirectoryName(ConfigPath)); AmeisenBot = new AmeisenBot(BotDataPath, playername, Config, Process.GetCurrentProcess().MainWindowHandle); AmeisenBot.WowInterface.ObjectManager.OnObjectUpdateComplete += OnObjectUpdateComplete; AmeisenBot.StateMachine.OnStateMachineStateChanged += OnStateMachineStateChange; LastStateMachineTickUpdate = DateTime.Now; } if (AmeisenBot != null) { AmeisenBot.Start(); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { // obtain a window handle (HWND) to out current WPF window MainWindowHandle = new WindowInteropHelper(this).EnsureHandle(); comboboxStateOverride.Items.Add(BotMode.None); comboboxStateOverride.Items.Add(BotMode.Grinding); comboboxStateOverride.Items.Add(BotMode.Jobs); comboboxStateOverride.Items.Add(BotMode.PvP); comboboxStateOverride.Items.Add(BotMode.Questing); comboboxStateOverride.Items.Add(BotMode.Testing); comboboxStateOverride.SelectedIndex = 0; // display the PID, maybe remove this when not debugging labelPID.Content = $"PID: {Environment.ProcessId}"; if (TryLoadConfig(ConfigPath, out AmeisenBotConfig config)) { AmeisenBot = new(config); // capture whisper messages and display them in the bots ui as a flashing button AmeisenBot.Bot.Wow.Events?.Subscribe("CHAT_MSG_WHISPER", OnWhisper); // events used to update our GUI AmeisenBot.Bot.Objects.OnObjectUpdateComplete += OnObjectUpdateComplete; // handle the autoposition function where the wow window gets "absorbed" by the bots window if (AmeisenBot.Config.AutoPositionWow) { // this is used to measure the size of wow's window PresentationSource presentationSource = PresentationSource.FromVisual(this); M11 = presentationSource.CompositionTarget.TransformToDevice.M11; M22 = presentationSource.CompositionTarget.TransformToDevice.M22; AmeisenBot.Logic.OnWoWStarted += () => { Dispatcher.Invoke(() => { AmeisenBot.Bot.Memory.SetupAutoPosition ( MainWindowHandle, (int)((wowRect.Margin.Left + 1) * M11), (int)((wowRect.Margin.Top + 1) * M22), (int)((wowRect.ActualWidth - 1) * M11), (int)((wowRect.ActualHeight - 1) * M22) ); }); IsAutoPositionSetup = true; }; } AmeisenLogger.I.Log("AmeisenBot", "Loading Hotkeys", LogLevel.Verbose); LoadHotkeys(); AmeisenBot.Start(); StateConfigWindows = new() { { BotMode.Jobs, new StateJobConfigWindow(AmeisenBot, AmeisenBot.Config) }, { BotMode.Grinding, new StateGrindingConfigWindow(AmeisenBot, AmeisenBot.Config) },
private void Window_Loaded(object sender, RoutedEventArgs e) { AmeisenBot.Start(); }