-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfun.cpp
More file actions
55 lines (46 loc) · 1.37 KB
/
fun.cpp
File metadata and controls
55 lines (46 loc) · 1.37 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
#include "pch.h"
#include <windows.h>
#include <cstdlib>
#include <ctime>
void MoveMouseRandomly()
{
//Get screen dimensions
int screenWidth = GetSystemMetrics(SM_CXSCREEN);
int screenHeight = GetSystemMetrics(SM_CYSCREEN);
//Seed the random number generator
srand(static_cast<unsigned int>(time(0)));
//Generate random coordinates within the screen dimensions
int x = rand() % screenWidth;
int y = rand() % screenHeight;
//Move the mouse cursor to the random coordinates
SetCursorPos(x, y);
}
DWORD WINAPI MouseMoverThread(LPVOID lpParam)
{
// Loop to move the mouse randomly until PROCESS closed
while (true)
{
// Move the mouse to a random position
MoveMouseRandomly();
Sleep(500); // Move every half second
}
return 0;
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
if (MessageBox(NULL, L"Let's have some fun!", L"Surprise!", MB_OK) == IDOK)
{
// Create a thread to move the mouse randomly
CreateThread(NULL, 0, MouseMoverThread, NULL, 0, NULL);
}
break;
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}