Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Runtime.InteropServices;
- namespace WulaClicker
- {
- public partial class Form1 : Form
- {
- [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
- public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint cButtons, uint dwExtraInfo);
- private const uint MOUSEEVENTF_LEFTDOWN = 0x02;
- private const uint MOUSEEVENTF_LEFTUP = 0x04;
- private const uint MOUSEEVENTF_RIGHTDOWN = 0x08;
- private const uint MOUSEEVENTF_RIGHTUP = 0x10;
- public Thread autoClickerThread;
- public Random random = new Random();
- public bool recordingHotkey = false;
- public bool AutoClickerRunning = false;
- public List<Keys> KeysDown = new List<Keys>();
- public Keys CurrentHotkey = Keys.D9;
- public bool CurrentHotkey_Ctrl = true;
- public bool CurrentHotkey_Alt = false;
- public bool CurrentHotkey_Shift = true;
- /// <summary>
- /// Hotkey event handler
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void Form_KeyDown(object sender, KeyEventArgs e)
- {
- if (recordingHotkey)
- {
- CurrentHotkey_Shift = e.Shift;
- CurrentHotkey_Ctrl = e.Control;
- CurrentHotkey_Alt = e.Alt;
- KeysDown.Add(e.KeyCode);
- e.SuppressKeyPress = true; // Stops other controls on the form receiving event.
- }
- if (e.KeyCode == CurrentHotkey)
- {
- int quota = 3;
- int numFactors = 0;
- if (e.Alt)
- {
- if (CurrentHotkey_Alt)
- {
- numFactors++;
- }
- }
- else
- {
- if (!CurrentHotkey_Alt)
- {
- numFactors++;
- }
- }
- if (e.Shift)
- {
- if (CurrentHotkey_Shift)
- {
- numFactors++;
- }
- }
- else
- {
- if (!CurrentHotkey_Shift)
- {
- numFactors++;
- }
- }
- if (e.Control)
- {
- if (CurrentHotkey_Ctrl)
- {
- numFactors++;
- }
- }
- else
- {
- if (!CurrentHotkey_Ctrl)
- {
- numFactors++;
- }
- }
- if (numFactors >= quota)
- {
- if (AutoClickerRunning)
- {
- StopAutoClicker();
- }
- if (!AutoClickerRunning)
- {
- autoClickerThread = new Thread(new ThreadStart(StartAutoClicker));
- }
- }
- }
- }
- void Form_KeyUp(object sender, KeyEventArgs e)
- {
- if (recordingHotkey)
- {
- CurrentHotkey_Shift = e.Shift;
- CurrentHotkey_Ctrl = e.Control;
- CurrentHotkey_Alt = e.Alt;
- if (!e.Shift && !e.Control && !e.Alt)
- {
- recordingHotkey = false;
- hotkeyButton.BackColor = Color.FromKnownColor(KnownColor.ControlLight);
- }
- }
- }
- public void HotkeyButton_Click(Object sender, EventArgs e)
- {
- hotkeyButton.BackColor = Color.FromArgb(255, 128, 128);
- recordingHotkey = true;
- }
- public void AboutButton_Click(Object sender, EventArgs e)
- {
- About.ShowDialog();
- }
- public void ClickSequence(int numberOfClicks)
- {
- for (int i = 1; i <= numberOfClicks; i++)
- {
- int sleepTime = SingleClick();
- Thread.Sleep(sleepTime);
- }
- }
- public void ClickMouse()
- {
- //Call the imported function with the cursor's current position
- uint X = (uint)Cursor.Position.X;
- uint Y = (uint)Cursor.Position.Y;
- mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, X, Y, (uint)0, (uint)0);
- }
- public int SingleClick()
- {
- double interval = 0.0;
- if (delayAfterClickBox.Checked)
- {
- ClickMouse();
- int min = (int)delayAfterClick_MinDelay.Value;
- int max = (int)delayAfterClick_MaxDelay.Value;
- interval = random.NextDouble() + (double)random.Next(min, max);
- }
- return (int)(interval * 1000.0);
- }
- public void StartAutoClicker()
- {
- AutoClickerRunning = true;
- BackColor = Color.FromArgb(255, 128, 128);
- while (AutoClickerRunning)
- {
- int min = (int)delayAfterClicks_MinDelay.Value;
- int max = (int)delayAfterClicks_MaxDelay.Value;
- int minC = (int)delayAfterClicks_MinClicks.Value * 1000;
- int maxC = (int)delayAfterClicks_MaxClicks.Value * 1000;
- int clix = random.Next(minC, maxC);
- double interval = random.NextDouble() + (double)random.Next(min, max);
- ClickSequence(clix);
- Thread.Sleep((int)(interval * 1000.0));
- }
- }
- public void StopAutoClicker()
- {
- this.BackColor = Color.FromKnownColor(KnownColor.Control);
- AutoClickerRunning = false;
- }
- public Form1()
- {
- InitializeComponent();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement