Help A Beginner With Random Number Generating?

Hey guys! So I'm a total beginner to programming and have decided to start with C++. I play an online video game called an MMORPG and am trying to make a program that will do a repetitive task over an over again in the game for me. I've already coded a very simple auto clicker that does what I need.

What I want to do now is modify the sleep and SetCursorPos to make them appear more human.

How would I go about turning Sleep (1000); into something like Sleep (any number between 950 and 1050;

Similarly, I'd like to do it for the SetCursorPos also.


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
#define WINVER 0x0500
#define _WIN32_WINNT 0x0500
#include <iostream>
#include <conio.h>
#include <windows.h>

using namespace std;

int main(){
for (;;) {
    // Set Cursor Position
    SetCursorPos(350, 500);

    // Mouse Event
    mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);

Sleep (1000);

    // Set Cursor Position
    SetCursorPos(1133, 337);

    // Mouse Event
    mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);

    Sleep(3000);

}
}


Thanks for the help!
Last edited on
Haha thats awesome! I've never seen that before.

I did find that page before I came here. Like I said Im knew to programming so I couldnt really figure it out.

To sleep the program at a random interval between 0 and 100 would I use
Sleep(rand() % 100;);

Thanks by the way!
np. i think it would %100 + 1 btw, but yes
If I want to sleep for an interval between 2990 and 3010 would I use

Sleep(rand() % 20 + 2990;);

edit** Program compiled and ran! Thanks!
Last edited on
Topic archived. No new replies allowed.