-
Notifications
You must be signed in to change notification settings - Fork 29
/
Process.cpp
79 lines (59 loc) · 1.43 KB
/
Process.cpp
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "Process.h"
#include <dwmapi.h>
#pragma comment(lib, "Dwmapi.lib")
cProcess* Process = new cProcess();
bool cProcess::attachProcess(std::string Process)
{
while (!Mem->hProcess)
{
Mem->Process(Process.c_str());
}
return true;
}
bool cProcess::setWindow(std::string Window)
{
targetWindow = FindWindow(NULL, Window.c_str());
if (!targetWindow)
return false;
if (!getSize())
return false;
return true;
}
bool cProcess::getSize()
{
if (!GetWindowRect(targetWindow, &WindowRect))
exit(1);
DwmGetWindowAttribute(targetWindow, DWMWA_EXTENDED_FRAME_BOUNDS, &frame, sizeof(RECT));
RECT border;
border.left = frame.left - WindowRect.left;
border.top = frame.top - WindowRect.top;
border.right = WindowRect.right - frame.right;
border.bottom = WindowRect.bottom - frame.bottom;
WindowRect.left += border.left;
WindowRect.top += border.top;
WindowRect.right -= border.right;
WindowRect.bottom -= border.bottom;
Size[0] = WindowRect.right - WindowRect.left;
Size[1] = WindowRect.bottom - WindowRect.top -32;
Position[0] = WindowRect.left;
Position[1] = WindowRect.top +32;
return true;
}
bool cProcess::isWindowActive()
{
HWND ActiveWindow = GetForegroundWindow();
if (ActiveWindow != targetWindow && ActiveWindow != myWindow)
return false;
return true;
}
bool cProcess::isWindowMaximized()
{
if (IsZoomed(targetWindow) && !zoomOnce)
{
getSize();
zoomOnce = true;
return true;
}
else
return false;
}