help pleezz

my program writes wawawa, but i need to wwaaawawawwaaa, just write this randomly.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
#include <windows.h> 
#include <stdlib.h> 
using namespace std; 

int main () 
{ 
  for(;;){ 
  Sleep(1000); 
  rand(); 
  keybd_event(VkKeyScan('w'),0,0,0); 
  Sleep(1000); 
  rand(); 
  keybd_event(VkKeyScan('a'),0,0,0); 
  } 
  return 0; 
}
rand returns a random number. Your code does nothing to that number. What you could be doing is
1
2
if(rand() % 2 == 0) ... 'w' ...;
else ... 'a' ...;

If the random number is even, print 'w', if it's odd, print 'a'.
Now i dont know where to include -sleep- element

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
#include <windows.h> 
#include <stdlib.h>
#include <cstdlib>
using namespace std;
int main(void)
{
   for(;;){      
   int a; 
   a = rand()%7;  
   if (a == 1)      
      {keybd_event(VkKeyScan('w'),0,0,0);} 
   else if (a == 2)
      keybd_event(VkKeyScan('a'),0,0,0);
   else if (a == 3)
      keybd_event(VkKeyScan('s'),0,0,0);
   else if (a == 4)
      keybd_event(VkKeyScan('d'),0,0,0);
   else if (a == 5)
      keybd_event(VkKeyScan('1'),0,0,0);
   else if (a == 6)
      keybd_event(VkKeyScan('2'),0,0,0);
   else 
      keybd_event(VkKeyScan('3'),0,0,0);
}
   return 0;
}
Now i dont know where to include -sleep- element
Before line 24. You just need to 'sleep' once
Topic archived. No new replies allowed.