2013-08-27 88 views
5

我想摆脱所有窗口上的最小化,最大化和关闭按钮。周围的Googling我发现这一点:获取所有打开的窗口使用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) 

这工作得很好,所以现在我只需要所有窗口迭代与此代码,我完成了。我如何获得系统中所有HWNDs的列表?

回答

6

你可以使用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 
+0

效果很好。谢谢! :) –

+1

如果匿名downvoter可以详细说明他的downvote的原因,这将是非常善良。如果你只是不明白答案,请发表评论,我会尽力帮助你。或者这只是一个热情的狂欢? http://fs2.directupload.net/images/150804/4pmpidv8.png – mrt