Advertisement
FichteFoll

_ScreenGetSize

Mar 18th, 2011
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 2.11 KB | None | 0 0
  1. ; #Function# ===========================================================================================================================================
  2. ; Name............: _ScreenGetSize
  3. ; Description.....: Returns an Rectangle containing the coordinates of the desktop without taskbar
  4. ; Syntax..........: _ScreenGetSize($fAlwaysVisible = False)
  5. ; Parameters......:
  6. ;                   $fAlwaysVisible - [optional] Taskbar is calculated as visible if it is not
  7. ; Return values .:
  8. ;                     Success    - Array with Rect structure [x1, y1, x2, y2]
  9. ;                     Failure    - 0 and sets error if the taskbar could not be found
  10. ; Author .........: FichteFoll
  11. ; Modified........:
  12. ; Remarks ........:
  13. ; Related ........: @DesktopWidth, @DesktopHeight
  14. ; Example ........; $ret = _ScreenGetSize()
  15. ;                   ConsoleWrite("" & $ret[4]
  16. ; ======================================================================================================================================================
  17. Func _ScreenGetSize($fAlwaysVisible = False)
  18.     Local $iPrevMode = AutoItSetOption("WinTitleMatchMode", 4), $aResult[4]
  19.     Local $aTaskBar_Pos = WinGetPos("[CLASS:Shell_TrayWnd]"), $aDesktop[2] = [@DesktopWidth, @DesktopHeight]
  20.     AutoItSetOption("WinTitleMatchMode", $iPrevMode)
  21.     If Not IsArray($aTaskBar_Pos) Then Return 0 * SetError(1)
  22.  
  23.     Local $i = ($aTaskBar_Pos[3] = $aDesktop[1]) ; 0 = top/bottom, 1 = left/right
  24.     $aResult[$i] = 0
  25.     $aResult[Not $i] = 0 + ($aTaskBar_Pos[Not $i] < $aDesktop[Not $i] / 2) _
  26.              * ($fAlwaysVisible * $aTaskBar_Pos[Not $i + 2]) _
  27.              + ($aTaskBar_Pos[Not $i] < $aDesktop[Not $i] / 2) _
  28.              * (Not $fAlwaysVisible * ($aTaskBar_Pos[Not $i] + $aTaskBar_Pos[Not $i + 2]))
  29.     $aResult[$i + 2] = $aDesktop[$i]
  30.     $aResult[Not $i + 2] = 0 + ($aTaskBar_Pos[Not $i] < $aDesktop[Not $i] / 2) * $aDesktop[Not $i] _
  31.              + ($aTaskBar_Pos[Not $i] > $aDesktop[Not $i] / 2) _
  32.              * ($fAlwaysVisible * ($aDesktop[Not $i] - $aTaskBar_Pos[Not $i + 2])) _
  33.              + ($aTaskBar_Pos[Not $i] > $aDesktop[Not $i] / 2) _
  34.              * (Not $fAlwaysVisible * $aTaskBar_Pos[Not $i])
  35.  
  36.     Return $aResult
  37. EndFunc   ;==>_ScreenGetSize
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement