Guest User

Slot Machine AFK Farmer

a guest
Apr 2nd, 2020
544
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.15 KB | None | 0 0
  1. #include <iostream>
  2. #include <Windows.h>
  3. #include <thread>
  4.  
  5. // String: $MPPLY_CASINO_CHIPS_WON_GD
  6. // Value: 0
  7.  
  8. void ThrowError(const char* Error)
  9. {
  10.     const auto hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  11.     SetConsoleTextAttribute(hConsole, 12);
  12.  
  13.     printf(Error, "\n");
  14.  
  15.     std::this_thread::sleep_for(std::chrono::seconds(3));
  16.     TerminateProcess(GetCurrentProcess(), 0);
  17.  
  18.     return;
  19. }
  20.  
  21. void ScanForExit()
  22. {
  23.     printf("Press F2 to stop the bot!\n");
  24.  
  25.     while (TRUE)
  26.     {
  27.         if (GetAsyncKeyState(VK_F2))
  28.         {
  29.             TerminateProcess(GetCurrentProcess(), 0);
  30.         }
  31.     }
  32.  
  33.     return;
  34. }
  35.  
  36. BOOLEAN PressEnter()
  37. {
  38.     auto Input = INPUT();
  39.     RtlZeroMemory(&Input, sizeof(Input));
  40.  
  41.     char Buffer[120] = { 0 };
  42.  
  43.     GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_ILANGUAGE, Buffer, sizeof(Buffer));
  44.     const auto hKeyboardLayout = LoadKeyboardLayoutA(Buffer, KLF_ACTIVATE);
  45.  
  46.     const auto EnterVk = VkKeyScanExA('\n', hKeyboardLayout);
  47.     const auto EnterVKey = MapVirtualKeyA(LOBYTE(EnterVk), 0);
  48.  
  49.     Input.type = INPUT_KEYBOARD;
  50.     Input.ki.dwFlags = KEYEVENTF_SCANCODE;
  51.     Input.ki.wScan = EnterVKey;
  52.  
  53.     SendInput(1, &Input, sizeof(Input));
  54.     RtlZeroMemory(&Input, sizeof(Input));
  55.  
  56.     std::this_thread::sleep_for(std::chrono::milliseconds(50));
  57.  
  58.     Input.type = INPUT_KEYBOARD;
  59.     Input.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP;
  60.     Input.ki.wScan = EnterVKey;
  61.  
  62.     SendInput(1, &Input, sizeof(Input));
  63.     RtlZeroMemory(&Input, sizeof(Input));
  64.  
  65.     return TRUE;
  66. }
  67.  
  68. BOOLEAN MouseClick()
  69. {
  70.     auto Input = INPUT();
  71.     RtlZeroMemory(&Input, sizeof(Input));
  72.  
  73.     Input.type = INPUT_MOUSE;
  74.     Input.mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
  75.  
  76.     SendInput(1, &Input, sizeof(Input));
  77.     RtlZeroMemory(&Input, sizeof(Input));
  78.  
  79.     Input.type = INPUT_MOUSE;
  80.     Input.mi.dwFlags = MOUSEEVENTF_LEFTUP;
  81.  
  82.     SendInput(1, &Input, sizeof(Input));
  83.     RtlZeroMemory(&Input, sizeof(Input));
  84.  
  85.     return TRUE;
  86. }
  87.  
  88. int main()
  89. {
  90.     printf("Press F1 to start the bot!\n");
  91.  
  92.     while (!GetAsyncKeyState(VK_F1))
  93.     {
  94.         std::this_thread::sleep_for(std::chrono::milliseconds(100));
  95.     }
  96.  
  97.     const auto GameWindow = FindWindowA("grcWindow", "Grand Theft Auto V");
  98.     const auto MenuWindow = FindWindowA(NULL, "5$ bronze pack recovery");
  99.  
  100.     if (GameWindow == NULL)
  101.     {
  102.         ThrowError("Couldn't find the game window, aborting...");
  103.         return -1;
  104.     }
  105.  
  106.     if (MenuWindow == NULL)
  107.     {
  108.         ThrowError("Couldn't find the menu window, aborting...");
  109.         return -1;
  110.     }
  111.  
  112.     printf("Game window: 0x%p\n", GameWindow);
  113.     printf("Menu window: 0x%p\n", MenuWindow);
  114.  
  115.     const auto hScanForExitThread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE)ScanForExit, 0, 0, 0);
  116.  
  117.     if (hScanForExitThread == NULL)
  118.     {
  119.         ThrowError("Failed to create exit thread, aborting...");
  120.         return -1;
  121.     }
  122.     else
  123.     {
  124.         CloseHandle(hScanForExitThread);
  125.     }
  126.  
  127.     while (TRUE)
  128.     {
  129.         SetForegroundWindow(GameWindow);
  130.         std::this_thread::sleep_for(std::chrono::milliseconds(100));
  131.         PressEnter();
  132.  
  133.         SetForegroundWindow(MenuWindow);
  134.         SetWindowPos(MenuWindow, NULL, 0, 0, 0, 0, SWP_NOSIZE);
  135.  
  136.         std::this_thread::sleep_for(std::chrono::milliseconds(250));
  137.  
  138.         SetCursorPos(100, 525);
  139.         MouseClick();
  140.         MouseClick();
  141.  
  142.         std::this_thread::sleep_for(std::chrono::seconds(1));
  143.     }
  144.  
  145.     return 0;
  146. }
Add Comment
Please, Sign In to add comment