Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // GetThreadID.cpp : This file contains the 'main' function. Program execution begins and ends there.
- //
- #include "pch.h"
- #include <iostream>
- #include <Windows.h>
- #include <fstream>
- #include <windef.h>
- #include <ctime>
- #include <time.h>
- #include <string>
- #include <wtypes.h>
- #include <array>
- using namespace std;
- void SimulateMouseClick();
- void PC(int x, int y);
- void MoveFor(int x);
- void MoveBack(int x);
- void MoveLeft(int x);
- void MoveRight(int x);
- void Message();
- void AFKCP();
- int GetChar(char x);
- void GetResolution(int &horizontal, int &vertical);
- string Messsage = "a";
- string McomMSim;
- /*template<class RECT>
- struct podrect
- {
- RECT left;
- RECT top;
- RECT right;
- RECT bottom;
- };
- template<class RECT>
- struct rect
- {
- rect() : left(), top(), right(), bottom() {}
- rect(RECT left, RECT top, RECT right, RECT bottom) :
- left(left), top(top), right(right), bottom(bottom) {}
- template<class Point>
- rect(Point p, RECT width, RECT height) :
- left(p.x), right(p.y), right(p.x + width), bottom(p.y + height) {}
- RECT left;
- RECT top;
- RECT right;
- RECT bottom;
- };
- typedef rect<int> intrect;
- typedef rect<float> floatrect;*/
- int horizontal, vertical = 0;
- const int KEYEVENT_KEY_ENTER = VK_RETURN;
- const int KEYEVENT_KEY_SHIFT = VK_LSHIFT;
- const int KEYEVENT_KEY_SEMICOLON = VK_OEM_1;
- int minOut = 0;
- const int KEYEVENT_KEY_A = 0x41;
- const int KEYEVENT_KEY_B = 0x42;
- const int KEYEVENT_KEY_C = 0x43;
- const int KEYEVENT_KEY_D = 0x44;
- const int KEYEVENT_KEY_E = 0x45;
- const int KEYEVENT_KEY_F = 0x46;
- const int KEYEVENT_KEY_G = 0x47;
- const int KEYEVENT_KEY_H = 0x48;
- const int KEYEVENT_KEY_I = 0x49;
- const int KEYEVENT_KEY_J = 0x4A;
- const int KEYEVENT_KEY_K = 0x4B;
- const int KEYEVENT_KEY_L = 0x4C;
- const int KEYEVENT_KEY_M = 0x4D;
- const int KEYEVENT_KEY_N = 0x4E;
- const int KEYEVENT_KEY_O = 0x4F;
- const int KEYEVENT_KEY_P = 0x50;
- const int KEYEVENT_KEY_Q = 0x51;
- const int KEYEVENT_KEY_R = 0x52;
- const int KEYEVENT_KEY_S = 0x53;
- const int KEYEVENT_KEY_T = 0x54;
- const int KEYEVENT_KEY_U = 0x55;
- const int KEYEVENT_KEY_V = 0x56;
- const int KEYEVENT_KEY_W = 0x57;
- const int KEYEVENT_KEY_X = 0x58;
- const int KEYEVENT_KEY_Y = 0x59;
- const int KEYEVENT_KEY_Z = 0x5A;
- int KeyCharArr[28] = { KEYEVENT_KEY_A, KEYEVENT_KEY_B, KEYEVENT_KEY_C, KEYEVENT_KEY_D, KEYEVENT_KEY_E, KEYEVENT_KEY_F, KEYEVENT_KEY_G, KEYEVENT_KEY_H, KEYEVENT_KEY_I, KEYEVENT_KEY_J, KEYEVENT_KEY_K, KEYEVENT_KEY_L, KEYEVENT_KEY_M, KEYEVENT_KEY_N, KEYEVENT_KEY_O, KEYEVENT_KEY_P, KEYEVENT_KEY_Q, KEYEVENT_KEY_R, KEYEVENT_KEY_S, KEYEVENT_KEY_T, KEYEVENT_KEY_U, KEYEVENT_KEY_V, KEYEVENT_KEY_W, KEYEVENT_KEY_X, KEYEVENT_KEY_Y, KEYEVENT_KEY_Z, VK_SPACE, KEYEVENT_KEY_SEMICOLON};
- int main()
- {
- GetResolution(horizontal, vertical);
- string id;
- DWORD Process_id;
- HWND hWND = FindWindowA(0, ("Wizard101"));
- //LPCSTR WindowName;
- //HWND hWND = FindWindowA(0, (WindowName));
- GetWindowThreadProcessId(hWND, &Process_id);
- std::cout << Process_id << std::endl;
- cout << "\nDo you want to spam a message? It must be longer than 2 letters, and only use lower case\nAnd use a period (.) to seperate words\n";
- cin >> Messsage;
- string RCB;
- cout << "\n Are you farming Rattle Bones (RB) or Couch Potatoes (CP) or BN or AFK?\n";
- cin >> RCB;
- ifstream File("Times.txt");
- // ofstream FFile("W.txt",fstream::app);
- //File.close();
- array <int, 8> T_id;
- for (size_t i = 0; i < T_id.size(); i++)
- {
- File >> T_id[i];
- }
- Sleep(5000);
- if (RCB == "AFK") {
- cout << "Do you want complex movement or simple back and forth? (Com || Sim)\n";
- cin >> McomMSim;
- }
- //<CP time>
- clock_t start = clock();
- double duration;
- tm time;
- start = clock();
- /*
- const double stHour = time.tm_hour;
- const double stMin = time.tm_min;
- const double stSec = time.tm_sec;*/
- //</CP time>
- while (hWND) {
- if (RCB == "AFK" && McomMSim == "Com") {
- AFKCP();
- }
- if (RCB == "AFK" && McomMSim == "Sim") {
- MoveFor(1500);
- Sleep(1000);
- MoveBack(1500);
- }
- if (RCB == "BN") {
- Sleep(1000);
- MoveBack(1000);
- keybd_event(KEYEVENT_KEY_X, 0, 0, 0);
- keybd_event(KEYEVENT_KEY_X, 0, KEYEVENTF_KEYUP, 0);
- Sleep(13000);
- MoveFor(8000);
- /*
- PC(538, 364); //card 1
- PC(621, 365); //card 2
- PC(576, 366);
- PC(677, 372); //card 3
- PC(745, 372); //card 4
- PC(683, 372);
- PC(821, 355); //card 5
- PC(887, 362); //card 6
- PC(779, 362);
- */
- PC(731, 374); // card 2
- PC(673, 371); // card 1
- PC(673, 371); // card 1
- PC(731, 374); // card 2
- PC(703, 371);//Combined Card
- Sleep(25000);
- MoveLeft(850);
- MoveFor(6000);
- }
- if (RCB == "RB") {
- Sleep(5000);
- MoveBack(T_id[0]); //T_id = 1
- MoveFor(T_id[1]); //T_id = 2
- PC(trunc(horizontal * 1.521961933), trunc(vertical * 1.471354));
- Sleep(2000);
- PC(trunc(horizontal * 1.4904), trunc(vertical * 1.471354));
- Sleep(2000);
- PC(trunc(horizontal * 1.51244), trunc(vertical * 1.471354));
- Sleep(22250);
- MoveLeft(T_id[2]); //T_id = 3
- MoveFor(T_id[3]); //T_id = 4
- }
- if (RCB == "CP") {
- //<Clicks the quit menu button incase it opens>
- if (Messsage.length() > 3) {
- SetCursorPos(trunc(horizontal * 1.7672), trunc(vertical * 1.8281)); //1048, 636
- Sleep(200);
- SimulateMouseClick();
- }
- //<Clicks the quit menu button incase it opens>
- //<pause>
- Sleep(500);
- //</pause>
- //<Card Clicking>
- PC(trunc(horizontal * 1.5219), trunc(vertical * 1.4843)); //713, 372
- Sleep(1500);
- PC(trunc(horizontal * 1.4963), trunc(vertical * 1.4296)); //678, 330
- Sleep(1500);
- PC(trunc(horizontal * 1.518), trunc(vertical * 1.4843)); //700, 374
- //<Card Clicking>
- //<Move to get into a new battle>
- MoveFor(750);
- MoveBack(650);
- //</move to get into a new battle>
- //<Prints the message>
- if (Messsage.length() > 2) {
- Message();
- }
- //</Prints the message>
- // //<time> I should really call this section time out / regeneration time
- duration = (std::clock() - start) / (double) CLOCKS_PER_SEC;
- int minutes = duration / 60;
- //if (minutes > 28){
- if (minOut <= 3) {
- minOut += 1;
- }
- else
- {
- minOut = 0;
- cout << minutes << endl;
- }
- if (minutes >= 35 && minutes <= 39) {
- // if (minutes >= 2 && minutes <= 5) {
- for (int i = 0; i <= 15; i++) {
- SetCursorPos(trunc(horizontal * 1.8374), trunc(vertical * 1.9062)); //1144, 696
- PC(trunc(horizontal * 1.8374), trunc(vertical * 1.9062)); //1144, 696
- SetCursorPos(trunc(horizontal * 1.5219), trunc(vertical * 1.4843)); //713, 372
- Sleep(100);
- SimulateMouseClick();
- Sleep(1500);
- }
- while (minutes >= 35 && minutes <= 39) {
- // while (minutes >= 2 && minutes <= 5) {
- AFKCP();
- duration = (std::clock() - start) / (double)CLOCKS_PER_SEC;
- minutes = duration / 60;
- if (minOut <= 10) {
- minOut += 1;
- }
- else
- {
- minOut = 0;
- cout << minutes << endl;
- }
- }
- SetCursorPos(trunc(horizontal * 1.9011), trunc(vertical * 1.9023)); //1231, 693
- PC(trunc(horizontal * 1.9011), trunc(vertical * 1.9023)); //1231, 693
- Sleep(5000);
- SetCursorPos(trunc(horizontal * 1.8799), trunc(vertical * 1.9309)); //1202, 715
- PC(trunc(horizontal * 1.8799), trunc(vertical * 1.9309)); //1202, 715
- MoveBack(3000);
- start = clock();
- Sleep(10000);
- }
- //}
- //</time>
- //<pause>
- Sleep(1000);
- //</pause>
- }
- }
- }
- void SimulateMouseClick() {
- //mouse_event(MOUSEEVENTF_LEFTDOWN, NULL, NULL, NULL, NULL);
- INPUT Input = { 0 };
- // left down
- Input.type = INPUT_MOUSE;
- Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
- ::SendInput(1, &Input, sizeof(INPUT));
- // left up
- ::ZeroMemory(&Input, sizeof(INPUT));
- Input.type = INPUT_MOUSE;
- Input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
- ::SendInput(1, &Input, sizeof(INPUT));
- }
- /*void KeyPress() {
- INPUT input;
- WORD vkey = VK_F12; // see link below
- input.type = INPUT_KEYBOARD;
- input.ki.wScan = MapVirtualKey(vkey, MAPVK_VK_TO_VSC);
- input.ki.time = 0;
- input.ki.dwExtraInfo = 0;
- input.ki.wVk = vkey;
- input.ki.dwFlags = 0; // there is no KEYEVENTF_KEYDOWN
- SendInput(1, &input, sizeof(INPUT));
- input.ki.dwFlags = KEYEVENTF_KEYUP;
- SendInput(1, &input, sizeof(INPUT));
- }*/
- void PC(int x, int y) {
- Sleep(600);
- SetCursorPos(x, y);
- Sleep(600);
- SimulateMouseClick();
- Sleep(600);
- }
- void Message() {
- Sleep(75);
- //Open Chat
- keybd_event(KEYEVENT_KEY_ENTER, 0, 0, 0);
- keybd_event(KEYEVENT_KEY_ENTER, 0, KEYEVENTF_KEYUP, 0);
- keybd_event(KEYEVENT_KEY_SHIFT, 0, 0, 0);
- //Put message here
- for (int i = 0; i < Messsage.length(); i++)
- {
- Sleep(50);
- keybd_event(GetChar(Messsage[i]), 0, 0, 0);
- keybd_event(GetChar(Messsage[i]), 0, KEYEVENTF_KEYUP, 0);
- }
- keybd_event(KEYEVENT_KEY_SHIFT, 0, KEYEVENTF_KEYUP, 0);
- //Sleep(5000);
- //Send Message
- keybd_event(KEYEVENT_KEY_ENTER, 0, 0, 0);
- keybd_event(KEYEVENT_KEY_ENTER, 0, KEYEVENTF_KEYUP, 0);
- }
- void AFKCP() {
- MoveFor(1500);
- MoveBack(750);
- MoveLeft(350);
- MoveFor(1500);
- MoveBack(1500);
- MoveRight(700);
- MoveFor(1500);
- MoveBack(1500);
- MoveLeft(350);
- MoveBack(750);
- }
- int GetChar(char x)
- {
- int number;
- int result;
- switch (x)
- {
- case('a'):
- number = 0;
- break;
- case('b'):
- number = 1;
- break;
- case('c'):
- number = 2;
- break;
- case('d'):
- number = 3;
- case('e'):
- number = 4;
- break;
- case('f'):
- number = 5;
- break;
- case('g'):
- number = 6;
- break;
- case('h'):
- number = 7;
- break;
- case('i'):
- number = 8;
- break;
- case('j'):
- number = 9;
- break;
- case('k'):
- number = 10;
- break;
- case('l'):
- number = 11;
- break;
- case('m'):
- number = 12;
- break;
- case('n'):
- number = 13;
- break;
- case('o'):
- number = 14;
- break;
- case('p'):
- number = 15;
- break;
- case('q'):
- number = 16;
- break;
- case('r'):
- number = 17;
- break;
- case('s'):
- number = 18;
- break;
- case('t'):
- number = 19;
- break;
- case('u'):
- number = 20;
- break;
- case('v'):
- number = 21;
- break;
- case('w'):
- number = 22;
- break;
- case('x'):
- number = 23;
- break;
- case('y'):
- number = 24;
- break;
- case('z'):
- number = 25;
- break;
- case('.'):
- number = 26;
- break;
- /*case('\0'): //
- number = 26;
- break;
- case('\r'): //
- number = 26;
- break;
- case(0x20): //
- number = 26;
- break;*/
- case(':'):
- number = 27;
- break;
- }
- switch (number)
- {
- case(0):
- result = KeyCharArr[0];
- break;
- case(1):
- result = KeyCharArr[1];
- break;
- case(2):
- result = KeyCharArr[2];
- break;
- case(3):
- result = KeyCharArr[3];
- case(4):
- result = KeyCharArr[4];
- break;
- case(5):
- result = KeyCharArr[5];
- break;
- case(6):
- result = KeyCharArr[6];
- break;
- case(7):
- result = KeyCharArr[7];
- break;
- case(8):
- result = KeyCharArr[8];
- break;
- case(9):
- result = KeyCharArr[9];
- break;
- case(10):
- result = KeyCharArr[10];
- break;
- case(11):
- result = KeyCharArr[11];
- break;
- case(12):
- result = KeyCharArr[12];
- break;
- case(13):
- result = KeyCharArr[13];
- break;
- case(14):
- result = KeyCharArr[14];
- break;
- case(15):
- result = KeyCharArr[15];
- break;
- case(16):
- result = KeyCharArr[16];
- break;
- case(17):
- result = KeyCharArr[17];
- break;
- case(18):
- result = KeyCharArr[18];
- break;
- case(19):
- result = KeyCharArr[19];
- break;
- case(20):
- result = KeyCharArr[20];
- break;
- case(21):
- result = KeyCharArr[21];
- break;
- case(22):
- result = KeyCharArr[22];
- break;
- case(23):
- result = KeyCharArr[23];
- break;
- case(24):
- result = KeyCharArr[24];
- break;
- case(25):
- result = KeyCharArr[25];
- break;
- case(26):
- result = KeyCharArr[26];
- break;
- case(27):
- result = KeyCharArr[27];
- break;
- }
- return result;
- }
- void GetResolution(int &horizontal, int &vertical) {
- RECT desktop;
- // Get a handle to the desktop window
- const HWND hDesktop = GetDesktopWindow();
- // Get the size of screen to the variable desktop
- GetWindowRect(hDesktop, &desktop);
- // The top left corner will have coordinates (0,0)
- // and the bottom right corner will have coordinates
- // (horizontal, vertical)
- horizontal = desktop.right;
- vertical = desktop.bottom;
- }
- void MoveFor(int x) {
- keybd_event(KEYEVENT_KEY_W, 0, 0, 0);
- Sleep(x);
- keybd_event(KEYEVENT_KEY_W, 0, KEYEVENTF_KEYUP, 0);
- }
- void MoveBack(int x) {
- keybd_event(KEYEVENT_KEY_S, 0, 0, 0);
- Sleep(x);
- keybd_event(KEYEVENT_KEY_S, 0, KEYEVENTF_KEYUP, 0);
- }
- void MoveLeft(int x)
- {
- keybd_event(KEYEVENT_KEY_A, 0, 0, 0);
- Sleep(x);
- keybd_event(KEYEVENT_KEY_A, 0, KEYEVENTF_KEYUP, 0);
- }
- void MoveRight(int x)
- {
- keybd_event(KEYEVENT_KEY_D, 0, 0, 0);
- Sleep(x);
- keybd_event(KEYEVENT_KEY_D, 0, KEYEVENTF_KEYUP, 0);
- }
- /*INPUT input; // INPUT structure
- memset(&input, 0, sizeof(input));
- // fill it out for keyboard key presses...
- input.type = INPUT_KEYBOARD;
- input.ki.wVk = VkKeyScanA('w');
- Sleep(2000);
- SendInput(1, &input, sizeof(INPUT)); // 3rd param is size of an INPUT structure
- // 2nd is LP to INPUT
- // 1st is number of structures..
- //modify the structure to do key up, a zero will indicate key down, as used above
- input.ki.dwFlags = KEYEVENTF_KEYUP;
- SendInput(1, &input, sizeof(INPUT));
- */
- /*INPUT input; // INPUT structure
- memset(&input, 0, sizeof(input));
- // fill it out for keyboard key presses...
- input.type = INPUT_KEYBOARD;
- input.ki.wVk = VkKeyScanA('w');
- Sleep(1500);
- SendInput(1, &input, sizeof(INPUT)); // 3rd param is size of an INPUT structure
- // 2nd is LP to INPUT
- // 1st is number of structures..
- //modify the structure to do key up, a zero will indicate key down, as used above
- input.ki.dwFlags = KEYEVENTF_KEYUP;
- SendInput(1, &input, sizeof(INPUT));*/
- /*Sleep(75);
- keybd_event(KEYEVENT_KEY_ENTER, 0, 0, 0);
- keybd_event(KEYEVENT_KEY_ENTER, 0, KEYEVENTF_KEYUP, 0);
- Sleep(75);
- keybd_event(KEYEVENT_KEY_I, 0, 0, 0);
- keybd_event(KEYEVENT_KEY_I, 0, KEYEVENTF_KEYUP, 0);
- Sleep(75);
- keybd_event(VK_SPACE, 0, 0, 0);
- keybd_event(VK_SPACE, 0, KEYEVENTF_KEYUP, 0);
- Sleep(75);
- keybd_event(KEYEVENT_KEY_A, 0, 0, 0);
- keybd_event(KEYEVENT_KEY_A, 0, KEYEVENTF_KEYUP, 0);
- Sleep(75);
- keybd_event(KEYEVENT_KEY_M, 0, 0, 0);
- keybd_event(KEYEVENT_KEY_M, 0, KEYEVENTF_KEYUP, 0);
- Sleep(75);
- keybd_event(VK_SPACE, 0, 0, 0);
- keybd_event(VK_SPACE, 0, KEYEVENTF_KEYUP, 0);
- Sleep(75);
- keybd_event(KEYEVENT_KEY_A, 0, 0, 0);
- keybd_event(KEYEVENT_KEY_A, 0, KEYEVENTF_KEYUP, 0);
- Sleep(75);
- keybd_event(VK_SPACE, 0, 0, 0);
- keybd_event(VK_SPACE, 0, KEYEVENTF_KEYUP, 0);
- Sleep(75);
- keybd_event(KEYEVENT_KEY_B, 0, 0, 0);
- keybd_event(KEYEVENT_KEY_B, 0, KEYEVENTF_KEYUP, 0);
- Sleep(75);
- keybd_event(KEYEVENT_KEY_O, 0, 0, 0);
- keybd_event(KEYEVENT_KEY_O, 0, KEYEVENTF_KEYUP, 0);
- Sleep(75);
- keybd_event(KEYEVENT_KEY_T, 0, 0, 0);
- keybd_event(KEYEVENT_KEY_T, 0, KEYEVENTF_KEYUP, 0);
- Sleep(75);
- keybd_event(KEYEVENT_KEY_ENTER, 0, 0, 0);
- keybd_event(KEYEVENT_KEY_ENTER, 0, KEYEVENTF_KEYUP, 0);*/
- /*
- if (hWND) {
- File << Process_id << "\n";
- cout << "Big Win";
- }
- else {
- File << "Window not found\n";
- cout << "Big sad";
- string x;
- while (!hWND) {
- cout << "Window not found\nDo you want to try again?";
- cin >> x;
- if (x == "Yes") {
- hWND = FindWindowA(0, ("Wizard101"));
- }
- else
- {
- break;
- }
- }
- }
- */
- /*
- // Run program: Ctrl + F5 or Debug > Start Without Debugging menu
- // Debug program: F5 or Debug > Start Debugging menu
- // Tips for Getting Started:
- // 1. Use the Solution Explorer window to add/manage files
- // 2. Use the Team Explorer window to connect to source control
- // 3. Use the Output window to see build output and other messages
- // 4. Use the Error List window to view errors
- // 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
- // 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement