-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cpp
More file actions
64 lines (47 loc) · 1.81 KB
/
Main.cpp
File metadata and controls
64 lines (47 loc) · 1.81 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
56
57
58
59
60
61
62
63
64
#include "Main.hpp"
const DWORD g_procId = GetCurrentProcessId();
int main() {
std::cout << "Start!" << std::endl;
std::map<HWND, RECT> windowsToRectsMap;
EnumWindows([](const _In_ HWND p_window, const _In_ LPARAM p_lParam) -> BOOL {
std::map<HWND, RECT> &windowsToRects = *(reinterpret_cast<std::map<HWND, RECT>*>(p_lParam));
DWORD procId = 0;
GetWindowThreadProcessId(p_window, &procId);
EnumChildWindows(p_window, [](const _In_ HWND p_window, const _In_ LPARAM p_lParam) -> BOOL {
std::map<HWND, RECT> &windowsToRects = *(reinterpret_cast<std::map<HWND, RECT>*>(p_lParam));
DWORD procId = 0;
GetWindowThreadProcessId(p_window, &procId);
if (procId != g_procId) {
windowsToRects[p_window] = {};
GetWindowRect(p_window, &windowsToRects[p_window]);
}
return TRUE;
}, reinterpret_cast<LPARAM>(&windowsToRects));
if (procId != g_procId) {
windowsToRects[p_window] = {};
GetWindowRect(p_window, &windowsToRects[p_window]);
}
return TRUE;
}, reinterpret_cast<LPARAM>(&windowsToRectsMap));
std::cout << "We have `" << windowsToRectsMap.size() << "` windows." << std::endl;
std::cout << "Press enter to make them spin." << std::endl;
#pragma warning(suppress:6031)
std::getchar();
std::cout << "Spinning began!" << std::endl;
ULONGLONG timeVar = GetTickCount64();
const ULONGLONG endTime = timeVar + 5000;
while (timeVar < endTime) {
timeVar = GetTickCount64();
for (auto &element : windowsToRectsMap) {
const HWND window = element.first;
RECT rect = element.second;
GetWindowRect(window, &rect);
const LONG animTime = timeVar / ULLONG_MAX * SPINWIN_TIME_SCALE;
MoveWindow(window,
rect.left + (LONG) (sin(animTime) * SPINWIN_AMP),
rect.top + (LONG) (cos(animTime) * SPINWIN_AMP),
rect.right - rect.left,
rect.bottom - rect.top, true);
}
}
}