Download: wowidlebot.cpp
- #define WIN32_LEAN_AND_MEAN
- #include <windows.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- DWORD GenerateSleepMilliseconds()
- {
- unsigned int range_min = 5*60; // 5 minutes
- unsigned int range_max = 8*60; // 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);
- }
- }












