我需要通过代码执行与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/