AutoIt – Return and Use Screen Height

email me

This is useful for adjusting the location of message boxes, forms, or other GUI components on the screen. When the height is returned, you can move it along the Y-axis. To use this, add the variable in the Y-axis element of that GUI component.

Example

$sAnswer = InputBox(“Computer Name”, “Enter Computer name or IP address”,””, “”,-1,-1,Default,$screenHeight)

 

Code

$screenHeight = _Desktop_Height()
$screenHeight = $screenHeight/2-150; move it up and down here

Func _Desktop_Height()
    Switch $height = ""
        Case @DesktopWidth = 640 And @DesktopHeight = 480;     
            $height = "480"
        Case @DesktopWidth = 800 And @DesktopHeight = 480;     
            $height = "480"
        Case @DesktopWidth = 854 And @DesktopHeight = 480;  
            $height = "480"
        Case @DesktopWidth = 800 And @DesktopHeight = 600;  
            $height = "600"
        Case @DesktopWidth = 960 And @DesktopHeight = 540;  
            $height = "540"
        Case @DesktopWidth = 1024 And @DesktopHeight = 576; 
            $height = "576"
        Case @DesktopWidth = 1024 And @DesktopHeight = 600; 
            $height = "600"
        Case @DesktopWidth = 1024 And @DesktopHeight = 768; 
            $height = "768"
        Case @DesktopWidth = 1152 And @DesktopHeight = 864; 
            $height = "864"
        Case @DesktopWidth = 1280 And @DesktopHeight = 720; 
            $height = "720"
        Case @DesktopWidth = 1280 And @DesktopHeight = 768; 
            $height = "768"
        Case @DesktopWidth = 1280 And @DesktopHeight = 800; 
            $height = "800"
        Case @DesktopWidth = 1280 And @DesktopHeight = 960; 
            $height = "960"
        Case @DesktopWidth = 1280 And @DesktopHeight = 1024;
            $height = "1024"
        Case @DesktopWidth = 1360 And @DesktopHeight = 768; 
            $height = "768"
        Case @DesktopWidth = 1366 And @DesktopHeight = 768; 
            $height = "768"
        Case @DesktopWidth = 1440 And @DesktopHeight = 900; 
            $height = "900"
        Case @DesktopWidth = 1400 And @DesktopHeight = 1050;
            $height = "900"
        Case @DesktopWidth = 1600 And @DesktopHeight = 900; 
            $height = "900"
        Case @DesktopWidth = 1600 And @DesktopHeight = 1200;
            $height = "1200"
        Case @DesktopWidth = 1680 And @DesktopHeight = 1050;
            $height = "1050"
        Case @DesktopWidth = 1920 And @DesktopHeight = 1080;
            $height = "1080"
        Case @DesktopWidth = 1920 And @DesktopHeight = 1200;
            $height = "1200"
        Case @DesktopWidth = 1920 And @DesktopHeight = 1400;
            $height = "1400"
        Case @DesktopWidth = 2048 And @DesktopHeight = 1080;
            $height = "1080"
        Case @DesktopWidth = 2048 And @DesktopHeight = 1152;
            $height = "1152"
        Case @DesktopWidth = 2048 And @DesktopHeight = 1536;
            $height = "1536"
        Case @DesktopWidth = 2538 And @DesktopHeight = 1080;
            $height = "1080"
        Case @DesktopWidth = 2560 And @DesktopHeight = 1080;
            $height = "1080"
        Case @DesktopWidth = 2560 And @DesktopHeight = 1440;
            $height = "1440"
        Case @DesktopWidth = 2560 And @DesktopHeight = 1600;
            $height = "1600"
        Case @DesktopWidth = 2560 And @DesktopHeight = 2048;
            $height = "2048"
        Case @DesktopWidth = 2880 And @DesktopHeight = 900; 
            $height = "900"
        Case Else
            Return SetError(1, 0, $height)
    EndSwitch
    Return $height
EndFunc   ;==>_Desktop_Height