使用AutoIt获取所有打开窗口的列表

Nic*_*aub 6 autoit

我试图摆脱所有窗口上的最小化,最大化和关闭按钮.谷歌搜索我发现这个:

$h = WinGetHandle("[CLASS:Notepad]")

$iOldStyle = _WinAPI_GetWindowLong($h, $GWL_STYLE)
$iNewStyle = BitXOr($iOldStyle, $WS_SYSMENU)
_WinAPI_SetWindowLong($h, $GWL_STYLE, $iNewStyle)
_WinAPI_ShowWindow($h, @SW_SHOW)
Run Code Online (Sandbox Code Playgroud)

这很好用,所以现在我只需要使用这段代码迭代所有窗口,我就完成了.如何获取系统中所有HWND的列表?

And*_*eas 8

您可以使用WinList获取所有打开窗口的列表:

$aWindows = WinList()
For $i=1 To $aWindows[0][0]

    ; skip windows without a title
    If $aWindows[$i][0] = '' Then ContinueLoop

    ;use the HWND to get the state of the window
    $iWndState =  WinGetState($aWindows[$i][1])

    ; here you could filter out the windows you don't want to modify
    ConsoleWrite($aWindows[$i][0] & ': ')
    If BitAND($iWndState,1) = 1 Then ConsoleWrite(' exists')
    If BitAND($iWndState,2) = 2 Then ConsoleWrite(' visible')
    If BitAND($iWndState,4) = 4 Then ConsoleWrite(' enabled')
    If BitAND($iWndState,8) = 8 Then ConsoleWrite(' active')
    If BitAND($iWndState,16) = 16 Then ConsoleWrite(' minimised')
    If BitAND($iWndState,32) = 32 Then ConsoleWrite(' maximised')
    ConsoleWrite(@CRLF)
Next
Run Code Online (Sandbox Code Playgroud)