【问题标题】:Get a list of all open windows using AutoIt使用 AutoIt 获取所有打开的窗口的列表
【发布时间】:2013-08-29 15:34:32
【问题描述】:

我正在尝试摆脱所有窗口上的最小化、最大化和关闭按钮。谷歌搜索我发现了这个:

$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)

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

【问题讨论】:

    标签: autoit


    【解决方案1】:

    您可以使用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
    

    【讨论】:

      猜你喜欢
      • 2014-08-27
      • 1970-01-01
      • 1970-01-01
      • 2015-10-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-08
      相关资源
      最近更新 更多