1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
#include <Windows.h>
using namespace std;
int main()
{
FreeConsole(); // This tells Windows this process is no longer using the console. This
// is a rather lame way to remove the console. A better way
// would be to simply not create a console program to begin with.
SwapMouseButton(true); // You are correct, this swap left and right mouse buttons
int i;
int X, Y; // you are correct, 3 integers, named i, X, Y
// This is a for loop. A for loop consists of 4 parts: initialization, condition, iteration, and body.
// the initialization is "i = 1". This is done at the start. This just assigns 1 to our i variable.
// The condition is "i < 1000". This is checked after initialization, and after each time the loop
// runs. If the condition is false, the loop exits. If the condition is true, the loop keeps
// looping.
// The iteration is "i++". This happens at the end of each loop. So this will increment i
// The body is everything inside the {braces}
//
// Effectively, i is just a counter which keeps track of how many times we loop. The loop is set
// to run exactly 999 times (each time, i will contain a different value).
for (i = 1; i < 1000; i++)
{
// rand() produces a random number
// % gives you the remainder after a division. IE: 7 % 3 == 1 because 7/3 has a remainder of 1
//
// A property of a remainder is that it will be >= 0 and < divisor.
// Therefore, when used with rand(), it effectively gives you a random number between [0,X)
X = rand() % 1035; // <- so this will make X be a random number between [0,1035)
Y = rand() % 769; // <- and Y is a random number betwee [0,769)
SetCursorPos(X, Y); // <- so we're basically moving the cursor to a random position on the screen
Sleep(10); // This does not sleep for 10 seconds, it sleeps for 10 milliseconds
// however, since the loop is run 999 times, the entire program will run for about 10 seconds
// but every 10ms, the cursor will move to another random place on the screen
}
SwapMouseButton(false);
}
|