winapi - 最小化所有打开的窗口?

标签 winapi

我需要通过代码执行与WindowsKey + M相同的任务,即。最小化所有打开的窗口。这必须通过 Win32 API 完成,而不是 .Net。

我在 FreeBasic 中尝试了以下操作,但没有任何反应:

Dim hWndConsole As HWND
'Shell_TrayWnd = class name of taskbar
Dim WindowName as String = "Shell_TrayWnd"

hWndConsole = FindWindow(0, strptr(WindowName))
ShowWindow(hWndConsole, SW_MINIMIZE) 'outta my sight

有人知道怎么做吗?

谢谢。


编辑:这是可行的解决方案:

#include "Windows.bi"

Dim hWndConsole As HWND
'Shell_TrayWnd = class name of taskbar
Dim WindowName as String = "Shell_TrayWnd"
Dim res as LRESULT
CONST minall = 419

hWndConsole = FindWindow( "Shell_TrayWnd",null)

res = postMessage(hWndConsole, WM_COMMAND,  minall, null )

最佳答案

这对我来说似乎有点黑客,但以下内容似乎确实完成了您正在寻找的内容(用 C 语言):

HANDLE hwnd = FindWindow( "Shell_TrayWnd", NULL );
LRESULT res = SendMessage( hwnd, WM_COMMAND, (WPARAM)419, 0 );

关于winapi - 最小化所有打开的窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13942765/

相关文章:

c++ - 在 PreTranslateMessage 中按 Ctrl+C 时接收 Ctrl+R 消息

c++ - 如何在没有数据竞争的情况下在一个套接字上实现具有并行请求和响应的非阻塞客户端-服务器通信模型

c++ - 如何在十六进制字符数组中插入十六进制值

c++ - 我可以使用什么 winapi C 函数调用将 unicode 转换为 ascii,反之亦然?

c# - 通过 SendMessage 或其他方式异步 GetForegroundWindow?

c++ - Win32 C++ 中的 DrawText 内存使用量增加

c++ - 在我的文档中创建文件夹

winapi - 使用 Win32 API 的 Windows "real"用户列表

c++ - 在作为函数参数的句柄上调用 CloseHandle?

c - 在 cmd 中打印和存储西类牙语字符(á、é、í、ñ...)