Created
July 6, 2019 21:20
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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