Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <thread>
- #include <chrono>
- #include <windows.h>
- void PrintError(const char *msg, bool pause = false, bool shutdown = true);
- void Sleep(int ms);
- int main() {
- int width, height;
- {
- RECT d;
- auto hD = GetDesktopWindow();
- GetWindowRect(hD, &d);
- width = d.right - 4;
- height = d.bottom;
- }
- INPUT ip;
- ip.type = INPUT_KEYBOARD;
- ip.ki.time = 0;
- ip.ki.dwFlags = KEYEVENTF_UNICODE;
- ip.ki.wScan = VK_RETURN; //VK_RETURN is the code of Return key
- ip.ki.wVk = 0;
- ip.ki.dwExtraInfo = 0;
- while (true) {
- POINT p;
- if (!GetCursorPos(&p))
- PrintError("Cannot get cursor pos");
- if (p.x >= width) {
- SendInput(1, &ip, sizeof(ip));
- Sleep(10 * 1000);
- }
- Sleep(500);
- }
- }
- void PrintError(const char *msg, bool pause, bool shutdown) {
- fprintf(stdout, "%s\n", msg);
- if (pause)
- std::cin.get();
- if (shutdown)
- exit(EXIT_FAILURE);
- }
- void Sleep(int ms) {
- std::this_thread::sleep_for(std::chrono::milliseconds(ms));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement