#define WIN32_LEAN_AND_MEAN
#include
#include
#include
#include
DWORD GenerateSleepMilliseconds()
{
unsigned int range_min = 560; // 5 minutes
unsigned int range_max = 860; // 8 minutes
DWORD u = (DWORD)(((double)rand() / (RAND_MAX + 1) (range_max - range_min) + range_min)1000);
return u;
}
int main(int argc, TCHAR * argv[])
{
DWORD sleepms = 0;
HWND handle = FindWindow(NULL, TEXT(“魔兽世界”));
if (handle == NULL)
{
return 1;
}
srand( (unsigned)time( NULL ) );
while (true)
{
SendMessage(handle, WM_KEYDOWN,VK_SPACE, 0);
SendMessage(handle, WM_KEYUP, VK_SPACE, 0);
sleepms = GenerateSleepMilliseconds();
printf_s("Sleep %d milliseconds.\n", sleepms);
Sleep(sleepms);
}
}