#include #include $sWindowToCheck = "AutoIt Help" $sControlToCheck = "Internet Explorer_Server1" ; Get a list of all windows ; Global $aWinList[1][7] = [ ["Title", "Handle", "X", "Y", "Width", "Height", "State"] ] Enum $WIN_TITLE, $WIN_HANDLE, $WIN_X, $WIN_Y, $WIN_WIDTH, $WIN_HEIGHT, $WIN_STATE $hwnd = WinGetHandle( $sWindowToCheck, "") If @error then Exit MsgBox(0, "error", "Error in getting hwnd" ) ; giving out results ConsoleWrite( "Window is blocked:" & WinIsBlocked($hwnd) & @CRLF ) ConsoleWrite( "Control is blocked:" & WinControlIsBlocked($hwnd, $sControlToCheck ) & @CRLF ) Func SetWinList(ByRef $aWinList) Local $aList = WinList() ; Loop up through the array For $i = $aList[0][0] To 1 Step -1 ; If there is no title or the window is not visible If $aList[$i][0] = "" Then ContinueLoop ; Remove the unshown ones $iState = WinGetState($aList[$i][1] ) If Not BitAND( $iState, $WIN_STATE_VISIBLE ) Then ContinueLoop If BitAND($iState, $WIN_STATE_MINIMIZED ) Then ContinueLoop ; Get the process details ; $iPID = WinGetProcess( $aList[$i][1] ) ; $sFullPath = _WinAPI_GetProcessFileName( $iPID ) $aPos = WinGetPos($aList[$i][1]) Local $aNew[1][7] = [ [ $aList[$i][0], $aList[$i][1], $aPos[0], $aPos[1], $aPos[2], $aPos[3], $iState ] ] _ArrayAdd( $aWinlist, $aNew ) Next EndFunc Func WinControlIsBlocked( $hWinHandle, $ControlID) ; return true if the Window is fully visible, nothing is blocking. Local $aWinList[0][7] SetWinList($aWinList) If UBound($aWinList) < 2 Then return SetError(1, 0, False) $iIndex = _ArraySearch( $aWinList, $hWinHandle, 0,0,0, 2, 1 ) If @error Then Return SetError(1, 0, False) ; The windows itself is not visible ; Now the Control $aPos = ControlGetPos($hWinHandle, "", $ControlID) If @error Then Return SetError(1, 0, False) $aWinClient = WinGetClientSize( $hWinHandle ) $iX_Offset = $aWinList[$iIndex][$WIN_WIDTH] - $aWinClient[0] - 6 $iY_Offset = $aWinList[$iIndex][$WIN_HEIGHT] - $aWinClient[1] - 6 $x = $aWinList[$iIndex][$WIN_X]+ $iX_Offset + $aPos[0] $y = $aWinList[$iIndex][$WIN_Y]+ $iY_Offset + $aPos[1] $w = $aPos[2] $h = $aPos[3] ; c( "x: " & $x & " y:" & $y & " w:" & $w & " h:" & $h) ; Is it top of the list? If $iIndex = UBound($aWinList)-1 Then Return False ; Local $x = $aPos[0], $y = $aPos[1], $w = $aPos[2], $h = $aPos[3] For $i = $iIndex+1 To UBound($aWinList)-1 ; the easy conditions If RectInRect( $aWinList[$i][$WIN_X], $aWinList[$i][$WIN_Y], $aWinList[$i][$WIN_WIDTH], $aWinList[$i][$WIN_HEIGHT], _ $x, $y, $w, $h ) Then Return True Next Return False EndFunc Func c($str) ConsoleWrite( $str & @crlf) EndFunc Func PointInRect ( $a, $b, $x, $y, $w, $h ) ; point $a, $b is within the rectangle $x,$y, $w, $h Return Within($a, $x, $w) And Within($b, $y, $h) EndFunc Func WinIsBlocked( $hWinHandle ) ; return true if the Window is fully visible, nothing is blocking. Local $aWinList[0][7] SetWinList($aWinList) If UBound($aWinList) < 2 Then return SetError(1, 0, False) $iIndex = _ArraySearch( $aWinList, $hWinHandle, 0,0,0, 2, 1 ) If @error Then Exit MsgBox(0, "error", "Error finding hwnd in the winlist. Error:" & @error ) ; Now have index, go down the win list ; Is it the last in the list? If $iIndex = UBound($aWinList)-1 Then Return False ; nothing is blocking it $x = $aWinList[$iIndex][$WIN_X] $y = $aWinList[$iIndex][$WIN_Y] $w = $aWinList[$iIndex][$WIN_WIDTH] $h = $aWinList[$iIndex][$WIN_HEIGHT] For $i = $iIndex+1 To UBound($aWinList)-1 ; the easy conditions If RectInRect ( $aWinList[$i][$WIN_X], $aWinList[$i][$WIN_Y], $aWinList[$i][$WIN_WIDTH], $aWinList[$i][$WIN_HEIGHT], _ $x, $y, $w, $h ) Then Return True Next Return False EndFunc Func RectInRect( $x1, $y1, $w1, $h1, $x2, $y2, $w2, $h2) If PointInRect( $x1, $y1, $x2, $y2, $w2, $h2) Then Return True If PointInRect( $x1+$w1, $y1, $x2, $y2, $w2, $h2) Then Return True If PointInRect( $x1, $y1+$h1, $x2, $y2, $w2, $h2) Then Return True If PointInRect( $x1+$w1, $y1+$h1, $x2, $y2, $w2, $h2) Then Return True ; 4 points are all not in the rect, maybe surrounding it. If $x1 < $x2 And $x1+$w1 > $x2+$w2 _ And $y1 < $y2 And $y1+$h1 > $y2+$h2 Then Return True EndFunc Func Within( $x, $from, $width ) ; c ( "x: " & $x & " from:" & $x & " width:" & $width & " Result:" & ($x > $from and $x < $from + $width) ) Return $x > $from and $x < $from + $width EndFunc