#include "Windows.h" #undef min #undef max #include #include #include #define F7_KEY 0x76 #define F8_KEY 0x77 HWND hwnd; std::mt19937 random; std::uniform_real_distribution random_click_x(0.6, 0.95); std::uniform_real_distribution random_click_y(0.25, 0.75); bool powers = false; bool clicks = false; void print() { system("CLS"); std::cout << "------------------------------------------------" << std::endl; std::cout << "Emu's Clicker Heroes" << std::endl << std::endl; std::cout << "[F7] Enabled = " << (clicks ? "TRUE" : "FALSE") << std::endl; std::cout << "[F8] Powers = " << (powers ? "TRUE" : "FALSE") << std::endl; std::cout << "------------------------------------------------" << std::endl; } void click(double x, double y) { RECT rect; GetClientRect(hwnd, &rect); int i_x = rect.right * x; int i_y = rect.bottom * y; LPARAM lparam = MAKELPARAM(i_x, i_y); PostMessage(hwnd, WM_LBUTTONDOWN, 0, lparam); Sleep(5); PostMessage(hwnd, WM_LBUTTONUP, 0, lparam); } void power(int vk) { PostMessage(hwnd, WM_KEYDOWN, vk, 0); Sleep(5); PostMessage(hwnd, WM_KEYUP, vk, 0); } void function1(void * arg) { int count = 0; while(1) { if(powers) { int msg = ((count + 0) % 256) == 0 ? WM_KEYDOWN : ((count + 1) % 256) == 0 ? WM_KEYUP : 0; if(msg) { PostMessage(hwnd, msg, '1', 0); PostMessage(hwnd, msg, '2', 0); PostMessage(hwnd, msg, '3', 0); PostMessage(hwnd, msg, '4', 0); PostMessage(hwnd, msg, '5', 0); PostMessage(hwnd, msg, '6', 0); PostMessage(hwnd, msg, '7', 0); } } if(clicks) { click(random_click_x(random), random_click_y(random)); } Sleep(20 + (rand() % 5)); count++; } } int main() { std::cout << "Looking for window..." << std::endl; hwnd = FindWindow(NULL, L"Clicker Heroes"); if(hwnd) { std::cout << "Window Found." << std::endl; print(); _beginthread(function1, 0, (void*)12); while(true) { if(GetAsyncKeyState(F8_KEY)) { powers = !powers; print(); } if(GetAsyncKeyState(F7_KEY)) { clicks = !clicks; print(); } Sleep(250); } } else { std::cout << "Could not find 'Clicker Heroes'" << std::endl; } std::cout << "Quitting..." << std::endl; Sleep(1000); return 0; }