Skip to content

Instantly share code, notes, and snippets.

@michaelneu
Created July 6, 2019 21:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelneu/6fa28d533c6acdba7dbba870fa8f18c0 to your computer and use it in GitHub Desktop.
Save michaelneu/6fa28d533c6acdba7dbba870fa8f18c0 to your computer and use it in GitHub Desktop.
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