[C++]天翼云电脑本机挂机隐藏窗口

废话不多说,直接贴代码。有想要解析的可以继续往下翻。
完整解决方案:KawaiiSh1zuku/CtYunAgentWindow

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
#include <iostream>
#include <windows.h>
#include <string.h>
#include <tchar.h>
#pragma comment(lib, "user32.lib")

int screenWidth = GetSystemMetrics(SM_CXSCREEN);
int screenHeight = GetSystemMetrics(SM_CYSCREEN);

BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lParam) {
char className[256];
GetClassNameA(hwnd, className, sizeof(className));

std::cout << "Child Window: " << className << std::endl;

RECT clientRect;
GetClientRect(hwnd, &clientRect);

RECT windowRect;
GetWindowRect(hwnd, &windowRect);

std::cout << "Client Area Resolution: " << clientRect.right - clientRect.left
<< " x " << clientRect.bottom - clientRect.top << std::endl;

std::cout << "Window Resolution: " << windowRect.right - windowRect.left
<< " x " << windowRect.bottom - windowRect.top << std::endl;

if (windowRect.right - windowRect.left < screenWidth && windowRect.bottom - windowRect.top < screenHeight) {
std::cout << "You are just the window I'm looking for!" << std::endl;
HWND hd = reinterpret_cast<HWND>(lParam);
if (IsWindowVisible(hd)) {
ShowWindow(hd, SW_HIDE);
std::cout << "Hid" << std::endl;
}
else {
ShowWindow(hd, SW_SHOW);
std::cout << "Shown" << std::endl;
}
return false;
}
return true;
}

int main(int argc, _TCHAR* argv[])
{
HWND hd = GetDesktopWindow();

hd = GetWindow(hd, GW_CHILD);
char s[200] = { 0 };

while (hd != NULL)
{
memset(s, 0, 200);
GetWindowText(hd, s, 200);
if (strstr(s,"CtyunClouddeskUniversal"))
{
EnumChildWindows(hd, EnumChildProc, reinterpret_cast<LPARAM>(hd));
}
hd = GetNextWindow(hd, GW_HWNDNEXT);
}

return 0;
}

解析:用遍历取得客户端的窗口,然后判断是不是我们想要隐藏/显示的窗口(有一个覆盖了全屏的窗口,显示后会在顶层阻断鼠标操作)
至于为什么用遍历?不知道为什么用FindWindow找不到天翼云的窗口。

[C++]天翼云电脑本机挂机隐藏窗口

https://omn.cc/archives/49.html

作者

空指针

发布于

2023-12-31

更新于

2023-12-31

许可协议

You need to set install_url to use ShareThis. Please set it in _config.yml.
You forgot to set the business or currency_code for Paypal. Please set it in _config.yml.

评论

You forgot to set the shortname for Disqus. Please set it in _config.yml.
Your browser is out-of-date!

Update your browser to view this website correctly.&npsb;Update my browser now

×