Code:
#include <iostream>
#include <string>
#include <windows.h>
#include <winuser.h>
#include <iomanip>
#include <windows.h>
#include <Lmcons.h>
#include <conio.h>
using namespace std;
int main();
void startup();
void w(string par1);
void cl(int par1);
void pressKey(int keycode);
void holdKey(int key);
void releaseKey(int key);
string trim(string par1);
string flag = "";
char username[UNLEN+1];
string un;
DWORD username_len = UNLEN+1;
RECT gr;
HWND gHandle;
HANDLE cHandle = GetStdHandle(STD_OUTPUT_HANDLE);
int main()
{
// Set Title
SetConsoleTitle((LPCSTR)"Overwatch Hour Idler by ItsumiMPGH");
cout << "Type the passphrase from the original thread: ";
string input;
cin >> input;
if (input != "moiraistrash") {
exit(-1);
}
system("cls");
// Startup and attach to game
startup();
// Set overwatch text
cl(0x6);w("OHI/" + un);cl(0x7);w(" >> Hooking game...\n");
SetWindowText(gHandle, (LPCSTR)"Overwatch, Idling Hours by ItsumiMPGH");
GetWindowRect(gHandle, &gr);
// Greet the user
cl(0x6);w("OHI/" + un);cl(0x7);w(" >> ");cl(0xa);w("Welcome to ");cl(0xd);w("O");cl(0xa);w("verwatch ");cl(0xd);w("H");cl(0xa);w("our ");cl(0xd);w("I");cl(0xa);w("dler!\n");cl(0x7);
// Give the user instructions
cl(0x6);w("OHI/" + un);cl(0x7);w(" >> Please type 'help' for commands.\n");
// Let the user type commands
returntocommand:
while (flag == trim("")) {
cl(0x6);w("OHI/" + un);cl(0x7);w(" >> ");
cin >> flag;
}
if (flag == "exit") {
goto exitme;
} else if(flag == "help") {
cl(0x6);w("OHI/" + un);cl(0x7);w(" >> Command List:\n");
cl(0xa);
cout << setw(10) << "help" << " - Lists all available commands.\n";
cout << setw(10) << "exit" << " - Exits the program and cleans up attachment.\n";
cout << setw(10) << "idle" << " - Prompts you to join game and then idles for you.\n";
} else if (flag == "idle") {
cl(0x6);w("OHI/" + un);cl(0x7);w(" >> ");cl(0xa);w("Please enter any game. Then press Y. Hold Ctrl+V to stop.\n");cl(0x7);
if (getch() == 'y') {
cl(0x6);w("OHI/" + un);cl(0x7);w(" >> ");cl(0x6);w("Currently Idling...\n");
while (!(GetKeyState(VK_CONTROL) && GetKeyState('V'))) {
mouse_event(MOUSEEVENTF_LEFTDOWN, 90, gr.bottom - 155, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, 90, gr.bottom - 155, 0, 0);
Sleep(60);
mouse_event(MOUSEEVENTF_LEFTDOWN, 90, gr.bottom - 155, 0, 0);
mouse_event(MOUSEEVENTF_LEFTUP, 90, gr.bottom - 155, 0, 0);
holdKey(0x57);
mouse_event(MOUSEEVENTF_LEFTDOWN, 90, gr.bottom - 155, 0, 0);
Sleep(500);
mouse_event(MOUSEEVENTF_LEFTUP, 90, gr.bottom - 155, 0, 0);
releaseKey(0x57);
holdKey(0x44);
mouse_event(MOUSEEVENTF_LEFTDOWN, 90, gr.bottom - 155, 0, 0);
Sleep(500);
mouse_event(MOUSEEVENTF_LEFTUP, 90, gr.bottom - 155, 0, 0);
releaseKey(0x44);
holdKey(0x53);
mouse_event(MOUSEEVENTF_LEFTDOWN, 90, gr.bottom - 155, 0, 0);
Sleep(500);
mouse_event(MOUSEEVENTF_LEFTUP, 90, gr.bottom - 155, 0, 0);
releaseKey(0x53);
holdKey(0x41);
mouse_event(MOUSEEVENTF_LEFTDOWN, 90, gr.bottom - 155, 0, 0);
Sleep(500);
mouse_event(MOUSEEVENTF_LEFTUP, 90, gr.bottom - 155, 0, 0);
releaseKey(0x41);
}
cl(0x6);w("OHI/" + un);cl(0x7);w(" >> ");cl(0xc);w("Stopped Idling...\n");
MessageBoxA(gHandle, "OHI has stopped idling.", "Idling Complete", 0);
}
} else {
cl(0x6);w("OHI/" + un);cl(0x7);w(" >> ");cl(0xc);w("'" + flag + "' is not recognized as a command.\n");cl(0x7);
}
flag = "";
goto returntocommand;
exitme:
// Clean up
cl(0x6);w("OHI/" + un);cl(0x7);w(" >> Cleaning up...\n");
SetWindowText(gHandle, (LPCSTR)"Overwatch");
Sleep(2000);
return 0;
}
void startup() {
cl(0x6);
w("OHI/" + un);
cl(0x7);
w(" >> Starting up...\n");
Sleep(2000);
GetUserName(username, &username_len);
un = (string)username;
gHandle = FindWindowA(NULL, static_cast<LPCSTR>("Overwatch, Idling Hours by ItsumiMPGH"));
if (gHandle == NULL) {
gHandle = FindWindowA(NULL, static_cast<LPCSTR>("Overwatch"));
} else if (gHandle == NULL) {
cl(0x6);w("OHI/" + un);cl(0x7);w(" >> ");cl(0xc);w("Game is not running!!");cl(0x7);
Sleep(3000);
exit(-1);
}
}
void w(string par1) {
cout << par1;
}
void cl(int par1) {
SetConsoleTextAttribute(cHandle, par1);
}
string trim(string par1) {
return par1.erase(par1.find_last_not_of(" \n\r\t")+1);
}
void pressKey(int key) {
SetForegroundWindow(gHandle);
keybd_event(key, 0, 0, 0); //Press down the Key
keybd_event(key, 0, KEYEVENTF_KEYUP, 0); //Release the Key
}
void holdKey(int key) {
SetForegroundWindow(gHandle);
keybd_event(key, 0, 0, 0); // Press Down Key
}
void releaseKey(int key) {
SetForegroundWindow(gHandle);
keybd_event(key, 0, KEYEVENTF_KEYUP, 0); // Release Key
}