Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.13 KB | None | 0 0
  1. #include <iostream>
  2. #include <thread>
  3. #include <chrono>
  4.  
  5. #include <windows.h>
  6.  
  7. void PrintError(const char *msg, bool pause = false, bool shutdown = true);
  8.  
  9. void Sleep(int ms);
  10.  
  11. int main() {
  12.     int width, height;
  13.     {
  14.         RECT d;
  15.         auto hD = GetDesktopWindow();
  16.         GetWindowRect(hD, &d);
  17.         width = d.right - 4;
  18.         height = d.bottom;
  19.     }
  20.  
  21.     INPUT ip;
  22.     ip.type = INPUT_KEYBOARD;
  23.     ip.ki.time = 0;
  24.     ip.ki.dwFlags = KEYEVENTF_UNICODE;
  25.     ip.ki.wScan = VK_RETURN; //VK_RETURN is the code of Return key
  26.     ip.ki.wVk = 0;
  27.     ip.ki.dwExtraInfo = 0;
  28.  
  29.     while (true) {
  30.         POINT p;
  31.         if (!GetCursorPos(&p))
  32.             PrintError("Cannot get cursor pos");
  33.         if (p.x >= width) {
  34.             SendInput(1, &ip, sizeof(ip));
  35.             Sleep(10 * 1000);
  36.         }
  37.         Sleep(500);
  38.     }
  39. }
  40.  
  41. void PrintError(const char *msg, bool pause, bool shutdown) {
  42.     fprintf(stdout, "%s\n", msg);
  43.     if (pause)
  44.         std::cin.get();
  45.     if (shutdown)
  46.         exit(EXIT_FAILURE);
  47. }
  48.  
  49. void Sleep(int ms) {
  50.     std::this_thread::sleep_for(std::chrono::milliseconds(ms));
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement