private void btnStartBot_Click(object sender, EventArgs e) { try { AwakeningRoutines awakeRoutine = new AwakeningRoutines(this, ItemPosition, AwakeScrollPosition, ReversionPosition, InventoryRectangle, AwakeTypes); if (awakeRoutine.IsStopped()) { if (ItemPosition == Point.Empty || AwakeScrollPosition == Point.Empty || ReversionPosition == Point.Empty) { GeneralUtils.DisplayError("Set all of the item and scroll positions before starting the bot!"); return; } else if (cbConfigs.SelectedIndex == -1) { GeneralUtils.DisplayError("Select a server config before starting the bot!"); return; } else if (lviAwakes.Items.Count <= 0) { GeneralUtils.DisplayError("You need atleast one awake added!"); return; } } awakeRoutine.ToggleBotStatus(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void AwakeBotUserInterface_Load(object sender, EventArgs e) { // Remove the annoying double border from buttons when focus is occured btnItemPosition.GotFocus += (s, ev) => { ((Button)s).NotifyDefault(false); }; btnAwakeScrollPosition.GotFocus += (s, ev) => { ((Button)s).NotifyDefault(false); }; btnReversionScrollPosition.GotFocus += (s, ev) => { ((Button)s).NotifyDefault(false); }; btnSelectInventory.GotFocus += (s, ev) => { ((Button)s).NotifyDefault(false); }; btnItemPosition.MouseUp += (s, ev) => { if (TrySetAwakePosition((Control)s)) { ItemPosition = Cursor.Position; lblItemPosition.Text = ItemPosition.ToString(); } }; btnAwakeScrollPosition.MouseUp += (s, ev) => { if (TrySetAwakePosition((Control)s)) { AwakeScrollPosition = Cursor.Position; lblAwakePosition.Text = AwakeScrollPosition.ToString(); } }; btnReversionScrollPosition.MouseUp += (s, ev) => { if (TrySetAwakePosition((Control)s)) { ReversionPosition = Cursor.Position; lblReversionPosition.Text = ReversionPosition.ToString(); } }; if (!Directory.Exists(ConfigDirectory)) { Directory.CreateDirectory(ConfigDirectory); } string[] files = Directory.GetFiles(ConfigDirectory, "*.xml"); if (files.Length <= 0) { GeneralUtils.DisplayError("No server config files found"); } foreach (var file in files) { string fileName = file.Substring(file.LastIndexOf('\\') + 1); fileName = fileName.Substring(0, fileName.LastIndexOf('.')); cbConfigs.Items.Add(fileName); } }
private bool TrySetAwakePosition(Control control) { if (control.RectangleToScreen(control.DisplayRectangle).Contains(Cursor.Position)) { GeneralUtils.DisplayError("Click and drag the cursor to the item that will be awaked"); return(false); } control.BackColor = Color.FromArgb(11, 166, 65); return(true); }
private void btnDeleteAwake_Click(object sender, EventArgs e) { if (lviAwakes.SelectedIndices.Count > 0) { int selectedIndex = lviAwakes.SelectedIndices[0]; lviAwakes.Items.RemoveAt(selectedIndex); } else { GeneralUtils.DisplayError("Select an awake to delete!"); } }
private void IterateProcesses() { try { XmlDocument settings = new XmlDocument(); settings.Load(SettingsDir); var settingsRoot = settings.ChildNodes[1]; foreach (XmlNode settingsNode in settingsRoot) { foreach (XmlNode settingNode in settingsRoot.ChildNodes) { if (settingsNode.Name == "Setting") { string attrValue = settingsNode.Attributes[0].Value; if (attrValue == "ProcessName") { ProcessName = settingsNode.InnerText; } else if (attrValue == "BotWindowName") { BotWindowName = settingsNode.InnerText; } } } } } catch (Exception ex) { GeneralUtils.DisplayError(ex.ToString()); } var processes = System.Diagnostics.Process.GetProcessesByName(ProcessName); Processes.Clear(); foreach (var process in processes) { string[] processData = { process.ProcessName, process.Id.ToString() }; var listViewItem = new ListViewItem(processData); lviProcesses.Items.Add(listViewItem); IntPtr windowHandle = Process.GetWindowHandle(process.Id); Processes.Add(new Process(process.ProcessName, process.Id, process.Handle, windowHandle)); } if (Processes.Count <= 0) { GeneralUtils.DisplayError("Unable to find clients, please start the game then refresh."); } }
public AwakeningResolver(ServerConfigManager configManager, AwakeningRoutines awakeRoutines) { ConfigManager = configManager; AwakeRoutines = awakeRoutines; // Write the eng.user-words /* * string dictionary = ""; * * foreach (var awake in configManager.AwakeTypes) * { * dictionary += awake.Text + "\n"; * } * * using (StreamWriter sw = new StreamWriter("tessdata\\eng.user-words")) * { * sw.Write(dictionary); * } */ try { string characters = ""; foreach (char c in ConfigManager.WhitelistedCharacters) { characters += c; } var initVars = new Dictionary <string, object>() { { "load_system_dawg", false }, { "load_freq_dawg", false }, // { "user_words_suffix", "user-words" }, // Load custom dictionary from eng.user-words { "tessedit_char_whitelist", "+-%0123456789 " + characters }, }; TessEngine = new TesseractEngine("tessdata", ConfigManager.Language, EngineMode.Default, Enumerable.Empty <string>(), initVars, false) { DefaultPageSegMode = PageSegMode.SingleBlock }; } catch (Exception ex) { GeneralUtils.DisplayError(ex.ToString()); Application.Exit(); } }
private void btnApplyAwake_Click(object sender, EventArgs e) { int selectedComboIndex = cbAwakeType.SelectedIndex; if (selectedComboIndex == -1) { GeneralUtils.DisplayError("Please select an awake type!"); return; } int awakeValue = (int)numericAwakeValue.Value; string[] awake = { selectedComboIndex.ToString(), AwakeTypes.AwakeTypes[selectedComboIndex].Name, awakeValue.ToString() }; lviAwakes.Items.Add(new ListViewItem(awake)); gbNewAwake.Visible = false; }
/// <summary> /// Parses the config and sets all variables appropriately. /// </summary> private void ParseConfig() { try { XmlDocument awakeTypeDoc = new XmlDocument(); awakeTypeDoc.Load(ConfigDirectory + "\\" + ConfigName + ".xml"); XmlElement root = awakeTypeDoc.DocumentElement; ReadAwakeTypes(root); foreach (var awake in AwakeTypes) { foreach (char c in awake.Text) { WhitelistedCharacters.Add(c); } } string pixelColor = ReadSettingValue(root, "AwakeTextPixelColorRgb"); AwakeTextPixelColor = ConvertRgbColorString(pixelColor); string scrollDelay = ReadSettingValue(root, "ScrollDelayMs"); ScrollDelay = Convert.ToInt32(scrollDelay); if (scrollDelay == null) { ScrollDelay = 200; } Language = ReadSettingValue(root, "Language"); } catch (FileNotFoundException) { GeneralUtils.DisplayError("Unable to load awake config " + ConfigDirectory); } catch (Exception ex) { GeneralUtils.DisplayError("Unable to parse config\n\n" + ex.ToString()); } }
public AwakeningResolver(ServerConfigManager configManager, AwakeningRoutines awakeRoutines) { ConfigManager = configManager; AwakeRoutines = awakeRoutines; try { TessEngine = new TesseractEngine("tessdata", ConfigManager.Language); string characters = ""; foreach (char c in ConfigManager.WhitelistedCharacters) { characters += c; } TessEngine.SetVariable("tessedit_char_whitelist", "+-%0123456789 " + characters); TessEngine.DefaultPageSegMode = PageSegMode.SingleBlock; } catch (Exception ex) { GeneralUtils.DisplayError(ex.ToString()); Application.Exit(); } }
static void ErrorFileMissing(string fileName) { GeneralUtils.DisplayError("Unable to start because " + fileName + " is not found."); }