Skip to content

Instantly share code, notes, and snippets.

@kauefraga
Created July 3, 2023 22:37
Show Gist options
  • Save kauefraga/bf91c75c498fec9274ca795d5ec10362 to your computer and use it in GitHub Desktop.
Save kauefraga/bf91c75c498fec9274ca795d5ec10362 to your computer and use it in GitHub Desktop.
🖱 A code that move the cursor randomly in the screen (1280x720).
#include <windows.h>
#include <thread>
namespace screen {
const int WIDTH = 1280;
const int HEIGHT = 720;
}
int main() {
// Seeding with current time
srand(time(NULL));
while (!GetAsyncKeyState(VK_SPACE)) {
std::this_thread::sleep_for(std::chrono::milliseconds(200));
// Setting the positions relative to the screen size
int position[2] = { rand() % screen::WIDTH, rand() % screen::HEIGHT };
// Move the mouse cursor to
SetCursorPos(position[0], position[1]);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment