ESC = 종료버튼

F1 = 숨겨진 창 모두 복구

F2 = 창 숨기기 인데


F2를 눌러 창을 숨길 때 입력이 여러번 들어가 여러 창이 한 번에 사라지는데 한 번만 사라지게 할 순 없나요?


#include <stdio.h>

#include <Windows.h>

#include <conio.h>

#include <string.h>

#include<stack>

#include<string>

using namespace std;


bool func(char a[256]);

void HideWindow();

void ShowWindow();

stack<HWND> st = {};


char c;


int main()

{

ShowWindow(GetConsoleWindow(), SW_HIDE);

while(1)

{

if (GetKeyState(VK_ESCAPE) < 0)

{

ShowWindow();

ShowWindow(GetConsoleWindow(), SW_SHOW);

break;

}

if(GetAsyncKeyState(VK_F1)==0x8000)

ShowWindow();

else if(GetAsyncKeyState(VK_F2))

HideWindow();

}

}


bool func(char* a)

{

return strcmp(a, "MSTaskListWClass") && strcmp(a, "SysListView32")

&& strcmp(a, "Button") && strcmp(a, "Shell_TrayWnd") && strcmp(a,"DynamicContent2")

&&strcmp(a,"TrayNotifyWnd")!=0&&strcmp(a,"ToolbarWindow32")&&strcmp(a,"Start")&&strcmp(a,"TrayButton")

&&strcmp(a, "IMEModeButton") &&strcmp(a, "InputIndicatorButton")&&strcmp(a,"DynamicContent1")

&&strcmp(a, "TrayClockWClass");

}


void HideWindow()

{

HWND hWnd;

POINT point;


GetCursorPos(&point);

hWnd = WindowFromPoint(point);


char clsName_v[256];


GetClassNameA(hWnd, clsName_v, 256);

if (func(clsName_v))

{

st.push(hWnd);

ShowWindow(hWnd, SW_HIDE);

}

}


void ShowWindow()

{

while (!st.empty())

{

ShowWindow(st.top(), SW_SHOW);

st.pop();

}

}