-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPluginIsFullScreen.cpp
More file actions
77 lines (63 loc) · 1.68 KB
/
PluginIsFullScreen.cpp
File metadata and controls
77 lines (63 loc) · 1.68 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
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <Windows.h>
#include <Psapi.h>
#include <string>
#include "../../API/RainmeterAPI.h"
struct Measure
{
std::wstring processName;
Measure() {}
};
PLUGIN_EXPORT void Initialize(void** data, void* rm)
{
Measure* measure = new Measure;
*data = measure;
}
PLUGIN_EXPORT void Reload(void* data, void* rm, double* maxValue)
{
Measure* measure = (Measure*)data;
}
PLUGIN_EXPORT double Update(void* data)
{
Measure* measure = (Measure*)data;
measure->processName.clear();
double foundFullScreen = 0.0;
RECT appBounds = { 0 };
RECT screenBounds = { 0 };
HWND foregroundHandle = GetForegroundWindow();
GetWindowRect(GetDesktopWindow(), &screenBounds);
if (foregroundHandle != GetDesktopWindow() && foregroundHandle != GetShellWindow())
{
DWORD processPID;
GetWindowThreadProcessId(foregroundHandle, &processPID);
HANDLE processHandle = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processPID);
if (processHandle)
{
WCHAR processName[MAX_PATH];
if (0 != GetModuleBaseName(processHandle, NULL, processName, MAX_PATH))
{
measure->processName = processName;
}
CloseHandle(processHandle);
}
GetWindowRect(foregroundHandle, &appBounds);
if (EqualRect(&appBounds, &screenBounds))
{
foundFullScreen = 1.0;
}
}
return foundFullScreen;
}
PLUGIN_EXPORT LPCWSTR GetString(void* data)
{
Measure* measure = (Measure*)data;
return measure->processName.c_str();
}
//PLUGIN_EXPORT void ExecuteBang(void* data, LPCWSTR args)
//{
// Measure* measure = (Measure*)data;
//}
PLUGIN_EXPORT void Finalize(void* data)
{
Measure* measure = (Measure*)data;
delete measure;
}