using System; using System.Collections.Generic; using System.Diagnostics; using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Text; using System.Globalization; using System.IO; using System.Runtime.InteropServices; using System.Text; using System.Threading; using System.Windows.Forms; internal class MainForm : Form { private delegate IntPtr HookProc(int n, IntPtr w, IntPtr l); private const int W = 780; private const int H = 500; private Slider sMin; private Slider sMax; private Seg sMode; private Seg sBtn; private Toggle tMc; private Graph gr; private System.Windows.Forms.Timer tick = new System.Windows.Forms.Timer(); private System.Windows.Forms.Timer fade = new System.Windows.Forms.Timer(); private volatile bool armed; private volatile bool clicking; private volatile bool ld; private volatile bool rd; private volatile bool run = true; private volatile bool breakMode; private double mn = 8.0; private double mx = 12.0; private double drift; private int mode = 2; private int btn; private int key = 117; private int breakKey = 118; private int hover; private int bindTarget; private int burstLeft; private bool onlyMc = true; private bool binding; private bool prevKey; private bool prevBreakKey; private long totalClicks; private double armStart = -1.0; private float fadeT; private float pulse; private IntPtr hook; private HookProc hp; private Random rnd = new Random(); private Stopwatch sw = Stopwatch.StartNew(); private List stamps = new List(); private Rectangle armR = new Rectangle(212, 86, 28, 28); private Rectangle keyR = new Rectangle(630, 164, 110, 28); private Rectangle keyR2 = new Rectangle(630, 276, 110, 28); private Rectangle minR = new Rectangle(704, 14, 24, 24); private Rectangle clsR = new Rectangle(736, 14, 24, 24); private int tab; private List[] tabs = new List[3] { new List(), new List(), new List() }; private string[] navs = new string[3] { "Clicker", "Settings", "Stats" }; private string ini = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "FloppaClicker\\settings.ini"); private Bitmap bgCache; [DllImport("user32")] private static extern IntPtr SetWindowsHookEx(int id, HookProc p, IntPtr m, uint t); [DllImport("user32")] private static extern bool UnhookWindowsHookEx(IntPtr h); [DllImport("user32")] private static extern IntPtr CallNextHookEx(IntPtr h, int n, IntPtr w, IntPtr l); [DllImport("kernel32")] private static extern IntPtr GetModuleHandle(string n); [DllImport("user32")] private static extern short GetAsyncKeyState(int k); [DllImport("user32")] private static extern void mouse_event(uint f, int x, int y, uint d, IntPtr e); [DllImport("user32")] private static extern IntPtr GetForegroundWindow(); [DllImport("user32", CharSet = CharSet.Unicode)] private static extern int GetWindowText(IntPtr h, StringBuilder s, int n); [DllImport("gdi32")] private static extern IntPtr CreateRoundRectRgn(int a, int b, int c, int d, int e, int f); [DllImport("user32")] private static extern bool ReleaseCapture(); [DllImport("user32")] private static extern IntPtr SendMessage(IntPtr h, int m, int w, int l); [DllImport("winmm")] private static extern uint timeBeginPeriod(uint p); public MainForm() { Text = "Floppa Clicker"; FormBorderStyle = FormBorderStyle.None; StartPosition = FormStartPosition.CenterScreen; ClientSize = new Size(780, 500); BackColor = G.Bg; DoubleBuffered = true; KeyPreview = true; Opacity = 0.0; Region = Region.FromHrgn(CreateRoundRectRgn(0, 0, 781, 501, 24, 24)); LoadCfg(); sMin = new Slider(1.0, 20.0); sMax = new Slider(1.0, 20.0); sMin.Value = mn; sMax.Value = mx; Slider slider = sMin; Action value = () => { if (sMin.Value > sMax.Value) { sMax.Value = sMin.Value; sMax.Invalidate(); } mn = sMin.Value; mx = sMax.Value; }; slider.Changed += value; sMax.Changed += () => { if (sMax.Value < sMin.Value) { sMin.Value = sMax.Value; sMin.Invalidate(); } mn = sMin.Value; mx = sMax.Value; }; sMode = new Seg("Constant", "Random", "Human"); sMode.Set(mode); sMode.Changed += () => { mode = sMode.Index; }; sBtn = new Seg("Left", "Right"); sBtn.Set(btn); sBtn.Changed += () => { btn = sBtn.Index; }; tMc = new Toggle(); tMc.Set(onlyMc); tMc.Changed += () => { onlyMc = tMc.On; }; gr = new Graph(); Put(sMode, 500, 220, 240, 28, 0); Put(sMin, 420, 275, 320, 30, 0); Put(sMax, 420, 331, 320, 30, 0); Put(sBtn, 570, 164, 170, 28, 1); Put(tMc, 696, 222, 44, 24, 1); Put(gr, 192, 112, 552, 170, 2); SetTab(0); hp = (int n, IntPtr w, IntPtr l) => { if (n >= 0 && (Marshal.ReadInt32(l, 12) & 1) == 0) { switch (w.ToInt32()) { case 513: ld = true; break; case 514: ld = false; break; case 516: rd = true; break; case 517: rd = false; break; } } return CallNextHookEx(hook, n, w, l); }; hook = SetWindowsHookEx(14, hp, GetModuleHandle(null), 0u); timeBeginPeriod(1u); tick.Interval = 60; tick.Tick += Tick; tick.Start(); fade.Interval = 15; fade.Tick += (object param0, EventArgs param1) => { fadeT += 3f / 76f; float num = Math.Min(1f, fadeT); Opacity = 1.0 - Math.Pow(1f - num, 3.0); if (num >= 1f) { Opacity = 1.0; fade.Stop(); } }; Thread thread = new Thread(Loop); thread.IsBackground = true; thread.Priority = ThreadPriority.AboveNormal; thread.Start(); BuildBg(); } private void BuildBg() { Bitmap image = new Bitmap(780, 500); using (Graphics graphics = Graphics.FromImage(image)) { graphics.SmoothingMode = SmoothingMode.AntiAlias; using (LinearGradientBrush brush = new LinearGradientBrush(new Rectangle(0, 0, 780, 500), Color.FromArgb(255, 18, 20, 28), Color.FromArgb(255, 9, 10, 14), 105f)) { graphics.FillRectangle(brush, 0, 0, 780, 500); } Glow(graphics, new PointF(655.19995f, 50f), 270f, Color.FromArgb(70, G.Acc)); Glow(graphics, new PointF(78f, 475f), 230f, Color.FromArgb(55, 255, 140, 195)); Glow(graphics, new PointF(390f, 240f), 360f, Color.FromArgb(22, G.Acc)); } bgCache = image; } private void Glow(Graphics g, PointF c, float r, Color col) { using GraphicsPath graphicsPath = new GraphicsPath(); graphicsPath.AddEllipse(c.X - r, c.Y - r, r * 2f, r * 2f); using PathGradientBrush pathGradientBrush = new PathGradientBrush(graphicsPath); pathGradientBrush.CenterColor = col; pathGradientBrush.SurroundColors = new Color[1] { Color.FromArgb(0, col) }; pathGradientBrush.CenterPoint = c; g.FillPath(pathGradientBrush, graphicsPath); } private void Put(Control c, int x, int y, int w, int h, int t) { c.SetBounds(x, y, w, h); Controls.Add(c); tabs[t].Add(c); } private void SetTab(int t) { tab = t; for (int i = 0; i < 3; i++) { foreach (Control item in tabs[i]) { item.Visible = i == t; } } Invalidate(); } protected override void OnShown(EventArgs e) { base.OnShown(e); fade.Start(); } protected override void OnFormClosed(FormClosedEventArgs e) { run = false; if (hook != IntPtr.Zero) { UnhookWindowsHookEx(hook); } SaveCfg(); base.OnFormClosed(e); } private void LoadCfg() { try { string[] array = File.ReadAllLines(ini); foreach (string text in array) { string[] array2 = text.Split('='); if (array2.Length == 2) { string text2 = array2[1].Trim(); switch (array2[0].Trim()) { case "min": mn = double.Parse(text2, CultureInfo.InvariantCulture); break; case "max": mx = double.Parse(text2, CultureInfo.InvariantCulture); break; case "mode": mode = int.Parse(text2); break; case "btn": btn = int.Parse(text2); break; case "mc": onlyMc = text2 == "1"; break; case "key": key = int.Parse(text2); break; case "bkey": breakKey = int.Parse(text2); break; } } } } catch { } } private void SaveCfg() { try { Directory.CreateDirectory(Path.GetDirectoryName(ini)); File.WriteAllText(ini, string.Format(CultureInfo.InvariantCulture, "min={0}\r\nmax={1}\r\nmode={2}\r\nbtn={3}\r\nmc={4}\r\nkey={5}\r\nbkey={6}\r\n", mn, mx, mode, btn, onlyMc ? 1 : 0, key, breakKey)); } catch { } } private bool Mc() { StringBuilder stringBuilder = new StringBuilder(256); GetWindowText(GetForegroundWindow(), stringBuilder, 256); string text = stringBuilder.ToString().ToLower(); if (!text.Contains("minecraft") && !text.Contains("lunar client") && !text.Contains("badlion")) { return text.Contains("labymod"); } return true; } private double Gauss() { double d = 1.0 - rnd.NextDouble(); double num = rnd.NextDouble(); return Math.Sqrt(-2.0 * Math.Log(d)) * Math.Cos(Math.PI * 2.0 * num); } private double NextMs() { double num = Math.Min(mn, mx); double num2 = Math.Max(mn, mx); double num3 = (num + num2) / 2.0; if (mode == 0) { return 1000.0 / Math.Max(0.5, num3); } double val; if (mode == 1) { val = num + rnd.NextDouble() * (num2 - num); return 1000.0 / Math.Max(0.5, val); } drift = Math.Max(-1.0, Math.Min(1.0, drift * 0.97 + Gauss() * 0.15)); val = num3 + drift * (num2 - num) / 2.0 + Gauss() * (num2 - num) * 0.12; val = Math.Max(num * 0.85, Math.Min(num2 * 1.15, val)); double num4 = 1000.0 / Math.Max(0.5, val); if (burstLeft > 0) { num4 *= 0.82; burstLeft--; } else if (rnd.NextDouble() < 0.025) { burstLeft = 2 + rnd.Next(3); } if (rnd.NextDouble() < 0.018) { num4 += 45.0 + rnd.NextDouble() * 90.0; } return num4; } private void Wait(double ms) { double num = sw.Elapsed.TotalMilliseconds + ms; while (sw.Elapsed.TotalMilliseconds < num) { Thread.Sleep(0); } } private void DoClick() { bool flag = btn == 0; mouse_event(flag ? 2u : 8u, 0, 0, 0u, IntPtr.Zero); Wait(4.0 + rnd.NextDouble() * 8.0); mouse_event(flag ? 4u : 16u, 0, 0, 0u, IntPtr.Zero); } private void Loop() { double num = -1.0; while (run) { bool flag = ((btn == 0) ? ld : rd); if (armed && !breakMode && flag && (!onlyMc || Mc())) { clicking = true; double totalMilliseconds = sw.Elapsed.TotalMilliseconds; DoClick(); totalClicks++; if (num > 0.0 && totalMilliseconds - num < 500.0) { gr.Add(totalMilliseconds - num); } num = totalMilliseconds; lock (stamps) { stamps.Add(totalMilliseconds); } double num2 = totalMilliseconds + NextMs(); while (run && sw.Elapsed.TotalMilliseconds < num2 && ((btn == 0) ? ld : rd)) { if (num2 - sw.Elapsed.TotalMilliseconds > 2.0) { Thread.Sleep(1); } else { Thread.SpinWait(30); } } } else { clicking = false; num = -1.0; Thread.Sleep(3); } } } private void Tick(object s, EventArgs e) { bool flag = (GetAsyncKeyState(key) & 0x8000) != 0; if (flag && !prevKey && !binding) { armed = !armed; if (armed) { totalClicks = 0L; armStart = sw.Elapsed.TotalMilliseconds; } else { armStart = -1.0; } } prevKey = flag; bool flag2 = (GetAsyncKeyState(breakKey) & 0x8000) != 0; if (flag2 && !prevBreakKey && !binding) { breakMode = !breakMode; } prevBreakKey = flag2; pulse = (pulse + 0.12f) % 6.2832f; lock (stamps) { double now = sw.Elapsed.TotalMilliseconds; stamps.RemoveAll((double x) => now - x > 1000.0); } if (tab == 2) { gr.Invalidate(); } Invalidate(); } protected override void OnKeyDown(KeyEventArgs e) { if (binding) { if (e.KeyCode != Keys.Escape) { if (bindTarget == 0) { key = (int)e.KeyCode; } else { breakKey = (int)e.KeyCode; } } binding = false; e.Handled = true; Invalidate(); } base.OnKeyDown(e); } protected override void OnMouseMove(MouseEventArgs e) { int num = (minR.Contains(e.Location) ? 1 : (clsR.Contains(e.Location) ? 2 : 0)); if (num != hover) { hover = num; Invalidate(new Rectangle(690, 8, 80, 40)); } Cursor = ((num > 0 || (tab == 0 && (armR.Contains(e.Location) || keyR.Contains(e.Location))) || (tab == 1 && keyR2.Contains(e.Location)) || (e.X < 160 && e.Y >= 76 && e.Y < 196)) ? Cursors.Hand : Cursors.Default); base.OnMouseMove(e); } protected override void OnMouseDown(MouseEventArgs e) { if (clsR.Contains(e.Location)) { Close(); } else if (minR.Contains(e.Location)) { WindowState = FormWindowState.Minimized; } else if (tab == 0 && armR.Contains(e.Location)) { armed = !armed; } else if (e.X < 160 && e.Y >= 76 && e.Y < 196) { SetTab((e.Y - 76) / 40); } else if (tab == 0 && keyR.Contains(e.Location)) { binding = true; bindTarget = 0; Invalidate(keyR); } else if (tab == 1 && keyR2.Contains(e.Location)) { binding = true; bindTarget = 1; Invalidate(keyR2); } else if (e.Y < 60 && e.Button == MouseButtons.Left) { ReleaseCapture(); SendMessage(Handle, 161, 2, 0); } base.OnMouseDown(e); } private void Row(Graphics g, int y, string t, string d) { G.T(g, t, G.H, G.Txt, 192f, y + 6, StringAlignment.Near); G.T(g, d, G.S, G.Dim, 192f, y + 28, StringAlignment.Near); using Pen pen = new Pen(G.Line); g.DrawLine(pen, 192, y + 54, 740, y + 54); } protected override void OnPaint(PaintEventArgs e) { Graphics graphics = e.Graphics; graphics.SmoothingMode = SmoothingMode.AntiAlias; graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit; if (bgCache != null) { graphics.DrawImageUnscaled(bgCache, 0, 0); } else { graphics.Clear(G.Bg); } using (SolidBrush brush = new SolidBrush(Color.FromArgb(90, 8, 9, 13))) { graphics.FillRectangle(brush, new Rectangle(0, 0, 168, 500)); } RectangleF r = new RectangleF(168f, 52f, 600f, 436f); using (GraphicsPath path = G.RR(r, 16f)) { using (SolidBrush brush2 = new SolidBrush(Color.FromArgb(160, G.Card.R, G.Card.G, G.Card.B))) { graphics.FillPath(brush2, path); } using Pen pen = new Pen(Color.FromArgb(50, 255, 255, 255), 1f); graphics.DrawPath(pen, path); } G.Fill(graphics, new RectangleF(20f, 16f, 30f, 30f), 15f, G.Acc); G.Circle(graphics, G.Logo, new RectangleF(21f, 17f, 28f, 28f)); G.T(graphics, "Floppa", G.H, G.Txt, 60f, 15f, StringAlignment.Near); G.T(graphics, "dev-local", G.S, G.Dim, 60f, 32f, StringAlignment.Near); for (int i = 0; i < 3; i++) { RectangleF r2 = new RectangleF(12f, 76 + i * 40, 136f, 34f); if (i == tab) { G.Fill(graphics, r2, 10f, G.Mix(G.Bg, G.Acc, 0.22f)); using SolidBrush brush3 = new SolidBrush(G.Acc); graphics.FillEllipse(brush3, 24, 88 + i * 40, 8, 8); } else { using SolidBrush brush4 = new SolidBrush(G.Dim); graphics.FillEllipse(brush4, 25, 89 + i * 40, 6, 6); } G.T(graphics, navs[i], G.N, (i == tab) ? G.Txt : G.Dim, 44f, 83 + i * 40, StringAlignment.Near); } G.T(graphics, "Armar: " + (Keys)key, G.S, G.Dim, 20f, 466f, StringAlignment.Near); if (hover == 1) { G.Fill(graphics, minR, 8f, G.Line); } if (hover == 2) { G.Fill(graphics, clsR, 8f, Color.FromArgb(200, 70, 70)); } using (Pen pen2 = new Pen(G.Txt, 1.6f)) { graphics.DrawLine(pen2, minR.X + 7, minR.Y + 12, minR.Right - 7, minR.Y + 12); graphics.DrawLine(pen2, clsR.X + 7, clsR.Y + 7, clsR.Right - 7, clsR.Bottom - 7); graphics.DrawLine(pen2, clsR.Right - 7, clsR.Y + 7, clsR.X + 7, clsR.Bottom - 7); } bool flag = !onlyMc || Mc(); string text; Color c; if (!armed) { text = string.Concat("Disarmed · press ", (Keys)key, " to arm"); c = G.Dim; } else if (breakMode) { text = "Mining mode · autoclick is paused"; c = G.Acc; } else if (!flag) { text = "Waiting for game · open Minecraft or Lunar Client"; c = G.Acc; } else if (clicking) { text = "Clicking · release to stop"; c = G.Ok; } else { text = "Ready · hold " + ((btn == 0) ? "left" : "right") + " click"; c = G.Ok; } int count; lock (stamps) { count = stamps.Count; } if (tab == 0) { G.Fill(graphics, new RectangleF(192f, 64f, 548f, 72f), 14f, Color.FromArgb(30, 32, 42)); if (armed) { using (SolidBrush brush5 = new SolidBrush(G.Acc)) { graphics.FillEllipse(brush5, armR); } using Pen pen3 = new Pen(Color.White, 2.4f); graphics.DrawLines(pen3, new PointF[3] { new PointF(219f, 100f), new PointF(224f, 105f), new PointF(233f, 95f) }); } else { using Pen pen4 = new Pen(G.Dim, 2f); graphics.DrawEllipse(pen4, armR); } G.T(graphics, "AutoClicker", G.H, G.Txt, 258f, 78f, StringAlignment.Near); G.T(graphics, text, G.S, c, 258f, 102f, StringAlignment.Near); G.T(graphics, count.ToString(), G.Big, clicking ? G.Acc : G.Dim, 720f, 70f, StringAlignment.Far); G.T(graphics, "Live CPS", G.S, G.Dim, 720f, 114f, StringAlignment.Far); Row(graphics, 150, "Arm key", "Key that arms and disarms the clicker."); Row(graphics, 206, "Mode", "Constant, random or human (with drift and micro-pauses)."); Row(graphics, 262, "Minimum CPS", "Minimum clicks per second."); Row(graphics, 318, "Maximum CPS", "Maximum clicks per second."); G.Fill(graphics, keyR, 10f, G.Bg); G.T(graphics, binding ? "Press a key…" : ((Keys)key).ToString(), G.S, binding ? G.Acc : G.Txt, keyR.X + keyR.Width / 2, keyR.Y + 5, StringAlignment.Center); return; } if (tab == 1) { G.T(graphics, "Settings", G.H, G.Txt, 192f, 66f, StringAlignment.Near); Row(graphics, 150, "Mouse button", "Button you need to hold down to click."); Row(graphics, 206, "Only inside Minecraft", "Only clicks while Minecraft, Lunar, Badlion or Labymod is focused."); Row(graphics, 262, "Break blocks", "Pauses the autoclick so you can mine without losing block progress."); G.Fill(graphics, keyR2, 10f, G.Bg); G.T(graphics, (binding && bindTarget == 1) ? "Press a key…" : ((Keys)breakKey).ToString(), G.S, (binding && bindTarget == 1) ? G.Acc : G.Txt, keyR2.X + keyR2.Width / 2, keyR2.Y + 5, StringAlignment.Center); G.T(graphics, breakMode ? "Active now" : "Inactive", G.S, breakMode ? G.Acc : G.Dim, 192f, 290f, StringAlignment.Near); return; } G.T(graphics, "Stats", G.H, G.Txt, 192f, 66f, StringAlignment.Near); G.T(graphics, "Click intervals", G.S, G.Dim, 192f, 90f, StringAlignment.Near); double[] array = gr.Snap(); double num = 0.0; double num2 = 0.0; if (array.Length > 2) { double[] array2 = array; foreach (double num3 in array2) { num += num3; } num /= (double)array.Length; double[] array3 = array; foreach (double num4 in array3) { num2 += (num4 - num) * (num4 - num); } num2 = Math.Sqrt(num2 / (double)array.Length); } G.T(graphics, (array.Length > 2) ? string.Format(CultureInfo.InvariantCulture, "Avg {0:0.0} CPS · Dev. {1:0} ms", 1000.0 / num, num2) : "Avg -- · Dev. --", G.N, G.Txt, 192f, 294f, StringAlignment.Near); G.T(graphics, "dotted line: 100 ms", G.S, G.Dim, 740f, 296f, StringAlignment.Far); G.T(graphics, count.ToString(), G.Big, clicking ? G.Acc : G.Dim, 192f, 330f, StringAlignment.Near); G.T(graphics, "Live CPS right now · " + text, G.S, G.Dim, 192f, 376f, StringAlignment.Near); double num5 = ((armed && armStart >= 0.0) ? ((double)totalClicks / Math.Max(0.5, (sw.Elapsed.TotalMilliseconds - armStart) / 1000.0)) : 0.0); G.T(graphics, armed ? (totalClicks + " clicks this session · " + num5.ToString("0.0", CultureInfo.InvariantCulture) + " avg CPS") : "No active session", G.S, G.Dim, 192f, 402f, StringAlignment.Near); } [STAThread] private static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(defaultValue: false); using (PasswordGate passwordGate = new PasswordGate()) { Application.Run(passwordGate); if (!passwordGate.Ok) { return; } } Application.Run(new Splash()); } }