private void DeleteButtonClick(object sender, EventArgs e) { ClickCollection clickCollection = _application.FindCollectionByName(_updatedListName); string filePath = Path.Combine(Application.FOLDER_PATH, clickCollection.Name + ".txt"); try { if (Directory.Exists(Application.FOLDER_PATH)) { if (File.Exists(filePath)) { File.Delete(filePath); } } } catch (IOException ioe) { Console.WriteLine(ioe.Message); } Application.availableLetters += clickCollection.Hotkey.ToString(); Application.activeHotkeys.Add(clickCollection.Hotkey); Console.WriteLine("Added " + clickCollection.Hotkey + " to the list."); _application.clickCollections.Remove(clickCollection); _application.DeleteFromTextBox(_updatedListName); _application.listEditFormIsOpen = false; Hide(); }
private void automateListButton_Click(object sender, EventArgs e) { if (GetSelectedClickCollection() == null) { MessageBox.Show("Please select a list to automate."); return; } ClickCollection clickCollection = GetSelectedClickCollection(); if (_automatedClickCollections.Contains(clickCollection)) { MessageBox.Show("You've already automated this list!"); return; } if (clickCollection.SingleLoop) { MessageBox.Show("Please toggle off your lists 'SingleLoop' setting before automating it."); return; } _automatedClickCollections.Add(clickCollection); automationListBox.Items.Add(clickCollection.Name); }
private void EditListButton(object sender, EventArgs e) { if (listEditFormIsOpen) { return; } if (listBox.SelectedItem == null) { MessageBox.Show("Please select the list you want to edit!"); return; } ClickCollection collection = GetSelectedClickCollection(); if (collection == null) { MessageBox.Show("Unexpected problem: couldn't find the selected list. \n Please contact the developer if the problem persists."); return; } ListEditForm listEditForm = new ListEditForm(this, collection.Name, collection.SingleLoop, collection.Hotkey, collection.ClickInterval); listEditForm.Show(); listEditFormIsOpen = true; }
private void SaveButtonClick(object sender, EventArgs e) { char newKey = GetLastCharacterFromString(hotkeyTextBox.Text); if (newKey != _oldHotkey) { if (Application.activeHotkeys.Contains(newKey) || !Application.availableLetters.Contains(newKey)) { MessageBox.Show("Couldn't register new hotkey! It's probably already in use.", "Error"); Console.WriteLine(Application.availableLetters); return; } else { Application.activeHotkeys.Remove(_oldHotkey); Application.activeHotkeys.Add(newKey); Application.availableLetters = Application.availableLetters += _oldHotkey; Application.availableLetters = Application.availableLetters.Replace(newKey.ToString(), string.Empty); hotkeyTextBox.Text = "CTRL + " + newKey; Console.WriteLine("Hotkey is now " + newKey); _hotkey = newKey; } } ClickCollection clickCollection = _application.FindCollectionByName(_originalListName); clickCollection.UpdateList(_updatedListName, _singleLoop, _hotkey, _clickSpeed); _application.UpdateTextBox(_originalListName, _updatedListName, _hotkey); _application.listEditFormIsOpen = false; Hide(); }
private void RegisterClickFromSequence(ClickPosition mouseClick) { if (!_recordingSequence) { return; } //Draw.DrawCircle(mouseClick.X, mouseClick.Y); ClickCollection collection = GetSelectedClickCollection(); collection.Clicks.Add(mouseClick); clickListBox.Items.Add(collection.Clicks.Count + ". X: " + mouseClick.X + " Y: " + mouseClick.Y + " Type: " + mouseClick.MouseButton); }
private void RegisterNewClickPosition(ClickPosition mouseClick) { if (listBox.SelectedItem == null) { return; } ClickCollection collection = GetSelectedClickCollection(); _registeringClickPosition = false; collection.Clicks.Add(mouseClick); clickListBox.Items.Add(collection.Clicks.Count + ". X: " + mouseClick.X + " Y: " + mouseClick.Y + " Type: " + mouseClick.MouseButton); this.WindowState = FormWindowState.Normal; }
private void automationListBox_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Delete && automationListBox.SelectedItem != null) { string str = automationListBox.SelectedItem.ToString(); string index = str[0].ToString(); ClickCollection collection = FindCollectionByName(str); automationListBox.Items.Remove(automationListBox.SelectedItem); _automatedClickCollections.Remove(collection); e.Handled = true; } }
private string ConvertDataToString(ClickCollection collection) { string contents = ""; contents += "WARNING: DO NOT MODIFY THE CONTENTS OF THIS FILE - DOING SO COULD CORRUPT THE LIST!" + Environment.NewLine;; contents += "SingleLoop:" + collection.SingleLoop + Environment.NewLine; contents += "Hotkey:" + collection.Hotkey + Environment.NewLine; contents += "ClickInterval:" + collection.ClickInterval + Environment.NewLine; contents += Environment.NewLine + "Clicks:" + Environment.NewLine; for (int i = 0; i < collection.Clicks.Count; i++) { contents += collection.Clicks[i].X + "," + collection.Clicks[i].Y + "-" + collection.Clicks[i].MouseButton + Environment.NewLine; } return(contents); }
private void RunCustomThread(char key) { try { if (_activeKey == (Keys)key) // terminate thread and return if user presses the current hotkey { Stop(); return; } if (_activeKey != Keys.None) // terminate current thread if it exists (but do not return) in preparation for starting the next one { Stop(); } ClickCollection clickCollection = FindCollectionByKey((Keys)key); if (clickCollection == null) { MessageBox.Show("Couldn't find the right list to activate...", "Error"); return; } if (clickCollection.Clicks.Count == 0) { MessageBox.Show("Your list doesn't contain any clicks.", "Error"); return; } WindowState = FormWindowState.Minimized; _activeKey = (Keys)key; CustomClickingThread customClickingThread = new CustomClickingThread(clickCollection.ClickInterval, clickCollection.SingleLoop, clickCollection.Clicks); if (clickCollection.SingleLoop) { customClickingThread.SingleLoopEvent += () => Invoke(new Action(() => Stop())); } _customClickThread = new Thread(new ThreadStart(customClickingThread.Run)); _customClickThread.Start(); } catch (Exception exc) { MessageBox.Show(exc.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void clickListBox_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Delete && clickListBox.SelectedItem != null) { ClickCollection collection = GetSelectedClickCollection(); if (collection == null) { return; } string str = clickListBox.SelectedItem.ToString(); int X = Convert.ToInt32(Utility.GetStringBetweenIndexes(str, str.IndexOf("X") + 2, str.IndexOf("Y") - 1)); int Y = Convert.ToInt32(Utility.GetStringBetweenIndexes(str, str.IndexOf("Y") + 2, str.IndexOf("T") - 1)); clickListBox.Items.Remove(clickListBox.SelectedItem); collection.Clicks.Remove(GetClickPositionByCoordinates(X, Y)); e.Handled = true; } }
private void AddListButton(object sender, EventArgs e) { if (availableLetters.Length == 0) { MessageBox.Show("You have too many lists! Please remove a list before adding a new one.", "Error"); return; } char randomChar = Utility.GetRandomLetter(); activeHotkeys.Add(randomChar); Console.WriteLine(randomChar + " was added."); availableLetters = availableLetters.Replace(randomChar.ToString(), string.Empty); ClickCollection clickCollection = new ClickCollection(new List <ClickPosition>(), Utility.GetRandomString(4), false, randomChar, 1); clickCollections.Add(clickCollection); listBox.Items.Add(clickCollection.Name + " - CTRL + " + clickCollection.Hotkey.ToString()); listBox.SetSelected(listBox.Items.Count - 1, true); }
private void LoadSettings() { if (!Directory.Exists(Application.FOLDER_PATH)) { return; } foreach (string file in Directory.EnumerateFiles(Application.FOLDER_PATH, "*.txt")) { if (file.Contains("AutomatedLists")) { continue; } string[] contents = File.ReadAllLines(file); string fileName = Path.GetFileName(file).Substring(0, Path.GetFileName(file).Length - 4); ClickCollection clickCollection = ConvertFileContentIntoCollection(contents, fileName); clickCollection.SavedName = clickCollection.Name; _application.clickCollections.Add(clickCollection); } _application.ListsAtStart = _clickCollections.Count; _application.UpdateLoadedListData(_clickCollections); }