Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Auto clicker for Starbound during the Steam summer sale. Works in the background, simply launch Starbound, spawn sodas and you're good to go.
using System;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
namespace ConsoleClicker
{
class Program
{
public const int WM_LBUTTONDOWN = 0x201;
public const int WM_LBUTTONUP = 0x202;
[DllImport("user32.dll")]
public static extern int SendMessage(int hWnd, int Msg, int wParam, int lParam);
static void Main(string[] args)
{
var starbound =
Process
.GetProcesses()
.Where(p => p.ProcessName == "starbound")
.FirstOrDefault();
if (starbound == null)
{
Console.WriteLine("couldn't find starbound.exe, exiting");
Environment.Exit(1);
return;
}
var starboundWindowHandle = starbound.MainWindowHandle.ToInt32();
// 70ms seems to be the sweet spot on my machine
// you can try to go lower though
var msBetweenClicks = 70;
var msBetweenDownAndUp = 1;
while (true)
{
SendMessage(starboundWindowHandle, WM_LBUTTONDOWN, 1, 0);
Thread.Sleep(msBetweenDownAndUp);
SendMessage(starboundWindowHandle, WM_LBUTTONUP, 0, 0);
Thread.Sleep(msBetweenClicks);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment