-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
37 lines (34 loc) · 884 Bytes
/
main.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
#include <Windows.h>
#include <stdio.h>
int WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int cmdShow)
{
if (!RegisterHotKey(
NULL,
1,
MOD_CONTROL | 0x4000,
VK_RETURN))
{
return 1;
}
MSG msg = {0};
while (GetMessage(&msg, NULL, 0, 0) != 0)
{
if (msg.message == WM_HOTKEY)
{
HWND handle = GetForegroundWindow();
// Toggle the window topmost state
if (GetWindowLong(handle, GWL_EXSTYLE) & WS_EX_TOPMOST)
{
SetWindowPos(handle, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}
else
{
SetWindowPos(handle, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}
}
}
return 0;
}