WinGet, OutputVar, List可以获得所有未隐藏窗口的列表。它显示的内容比用户在 Windows 任务栏上看到的内容要多得多。
如何将窗口数量限制为任务栏上显示的数量。就像任务管理器中的简单列表一样。(较少细节模式)
这是一种简单的方法,我不确定它是否可靠。
它的工作原理是尝试最小化窗口,如果它被最小化,则意味着它在任务栏上可用。
您可以以任何您需要的形式获取已找到/活动窗口的列表,这里我使用数组。
getWindows:
activeWindowsId := []
activeWindowsExe := []
newlist := ""
WinGet, List, List ;get the list of all windows
Sendinput, #m ;mimimize all windows by using the windows shortcut win+m
sleep, 200
;Loop % List ;or use this loop to minimze the windows
;{
; WinMinimize, % "ahk_id " List%A_Index%
;}
Loop % List
{
WinGet, theExe, ProcessName, % "ahk_id " List%A_Index% ;get the name of the exe
WinGet, windowState, MinMax, % "ahk_id " List%A_Index% ;get the state of the window, -1 is minimized, 1 is maximized, 0 is neither
if (windowState == -1) ;if the window is minimized
{
activeWindowsId.push(List%A_Index%) ;add the window id (hwnd) to this array
activeWindowsExe.push(theExe) ;add the window exe to this array
WinRestore, % "ahk_id " List%A_Index% ;restore the window
}
}
;read the found active windows list from the array to a string and show it with a msgbox
For index, exe in activeWindowsExe
{
newList .= exe "`n"
}
msgbox, % newList
return
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2584 次 |
| 最近记录: |