2013-08-27 86 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