Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.77 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <windows.h>
  3. #include <iostream>
  4. #include <time.h>
  5. #include <cstdlib>
  6. #include <string>
  7. #include <math.h>
  8. #include <conio.h>
  9. #include <signal.h>
  10. #include <stdlib.h>
  11. #include <cstdio>
  12. #include <tlhelp32.h>
  13. #include <sys/stat.h>
  14. #include <cctype>
  15. #include <cstdarg>
  16. #include <vector>
  17. #include <algorithm>
  18. // :^)
  19.  
  20. using namespace std;
  21. const char* LoLProcess = "League of Legends.exe";
  22. HWND LoLWindow;
  23. bool pressedf5 = false;
  24. bool isAlive(const char* pN);
  25. void emulatef5();
  26.  
  27. int main(char* envp[])
  28. {
  29.     cout << "quick simple yet so sharp auto f5 tool" << endl;
  30.     cout << endl;
  31.     while (1)
  32.     {
  33.         if (isAlive(LoLProcess) && !pressedf5)
  34.         {
  35.             LoLWindow = FindWindow(NULL, TEXT("League of Legends (TM) Client"));
  36.             SetForegroundWindow(LoLWindow);
  37.             Sleep(30000); //I think we have to wait for game to load? idk, change as needed.
  38.             cout << "Pressed F5 :)" << endl;
  39.             emulatef5();
  40.             pressedf5 = true;
  41.         }
  42.         if (!isAlive(LoLProcess))
  43.         {
  44.             pressedf5 = false;
  45.         }
  46.  
  47.     }
  48. }
  49.  
  50. void emulatef5()
  51. {
  52.     INPUT ip;
  53.     ip.type = INPUT_KEYBOARD;
  54.     ip.ki.wScan = 0;
  55.     ip.ki.time = 0;
  56.     ip.ki.dwExtraInfo = 0;
  57.  
  58.     // Press F5
  59.     ip.ki.wVk = VK_F5;
  60.     ip.ki.dwFlags = 0;
  61.     SendInput(1, &ip, sizeof(INPUT));
  62.  
  63.     // Release F5
  64.     ip.ki.wVk = VK_F5;
  65.     ip.ki.dwFlags = KEYEVENTF_KEYUP;
  66.     SendInput(1, &ip, sizeof(INPUT));
  67. }
  68. bool isAlive(const char* pN)
  69. {
  70.     HANDLE SnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  71.  
  72.     if (SnapShot == INVALID_HANDLE_VALUE)
  73.         return false;
  74.  
  75.     PROCESSENTRY32 procEntry;
  76.     procEntry.dwSize = sizeof(PROCESSENTRY32);
  77.  
  78.     if (!Process32First(SnapShot, &procEntry))
  79.         return false;
  80.  
  81.     do
  82.     {
  83.         if (strcmp(procEntry.szExeFile, pN) == 0)
  84.             return true;
  85.     } while (Process32Next(SnapShot, &procEntry));
  86.  
  87.     return false;
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement