简体   繁体   English

无法与视窗(HWND)cpp互动

[英]Can't interact with a window (HWND) cpp

I want to be able to minimize/maximize a window of a process that I create with ShellExecuteEx() . 我希望能够最小化/最大化我使用ShellExecuteEx()创建的进程的窗口。

First, I find the process ID and its HWND (I made sure it was the good HWND with Spy++). 首先,我找到进程ID及其HWND (我确定它是Spy ++的良好HWND )。

Next, I try to minimize with ShowWindow(hwnd) or with ShowWindow(GetForegroundWindow(), SW_MINIMIZE) . 接下来,我尝试使用ShowWindow(hwnd)ShowWindow(GetForegroundWindow(), SW_MINIMIZE)最小化。

But it doesn't work. 但这是行不通的。 I made sure the process was elevated (administrator rights). 我确保过程已提升(管理员权限)。 This seems to work with any other windows, such as the one for Notepad, RocketLeague, or whatever. 这似乎可以与其他任何窗口一起使用,例如记事本,RocketLeague或其他任何窗口。 But this one window doesn't react. 但是这个窗口没有反应。 When I call SetForegroundWindow(hwnd) I can see it flashing in the Taskbar, so I'm sure it is the right HWND for my application to use. 当我调用SetForegroundWindow(hwnd)我可以在任务SetForegroundWindow(hwnd)看到它的闪烁,因此我确定它是适合我的应用程序使用的HWND

Any idea of what the issue might be? 对这个问题可能有什么想法吗?

Use SPY++ to find className and windowName, then you can: 使用SPY ++查找className和windowName,然后可以:

HWND hWnd = ::FindWindow(className, windowName);
::ShowWindow(hWnd, SW_MINIMIZE);

SendMessage(GetForegroundWindow(),WM_SYSCOMMAND,SC_MINIMIZE,0);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM