This commit is contained in:
Vladimir Golubev 2023-03-10 02:26:27 +03:00
parent 248244b108
commit b4aa8ff165
2 changed files with 9 additions and 4 deletions

View File

@ -118,6 +118,7 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp20</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>

View File

@ -5,7 +5,6 @@
const MARGINS margins = { -1 ,-1, -1, -1 };
const wchar_t g_szClassName[] = L"overlay";
bool isVisible = true;
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
@ -13,11 +12,16 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
switch (msg)
{
case WM_HOTKEY:
if (wParam == 1) // При нажатии на горячую клавишу
if (wParam == 1) // При нажатии на горячую клавишу ALT + Z
{
isVisible = !isVisible; // Èíâåðòèðóåì çíà÷åíèå ïåðåìåííîé isVisible
ShowWindow(hwnd, isVisible ? SW_SHOW : SW_HIDE); // Ïîêàçûâàåì/ñêðûâàåì îêíî â çàâèñèìîñòè îò çíà÷åíèÿ isVisible
}
else if (wParam == 2) // При нажатии на горячую клавишу ALT + X
{
// Закрытие окна
DestroyWindow(hwnd);
}
break;
case WM_PAINT:
{
@ -40,8 +44,6 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
WNDCLASSEX wc;
@ -78,6 +80,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
// Ðåãèñòðàöèÿ ãîðÿ÷åé êëàâèøè
RegisterHotKey(hwnd, 1, MOD_ALT, 0x5A); // Çäåñü 0x5A ñîîòâåòñòâóåò êëàâèøå Z
RegisterHotKey(hwnd, 2, MOD_ALT, 0x58); // Здесь 0x58 соответствует клавише X
// Öèêë îáðàáîòêè ñîîáùåíèé
while (GetMessage(&Msg, NULL, 0, 0) > 0)
@ -88,6 +91,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
// Óäàëåíèå ãîðÿ÷åé êëàâèøè
UnregisterHotKey(hwnd, 1);
UnregisterHotKey(hwnd, 2);
exit(0);
return Msg.wParam;