Jump to content

Getting windows desktop size


Rad
 Share

Recommended Posts

Is there any way to get the width/height of the actual desktop, excluding the taskbar and sidebar(s)?

If you maximize a window they seem to know how big to become, but when you make a window that has @desktowidth // height as its size its fullscreen basically.

I could just subtract the width of the two, but I've done that before and it doesn't work right on someone elses computer (It's not dynamic)

There should be a way :)

I saw the helpfile mentioning WinGetClientSize("Program Manager"), but it still returns 1280x1024 (It should be around 1120x1000...ish)

kthx

Link to comment
Share on other sites

Is there any way to get the width/height of the actual desktop, excluding the taskbar and sidebar(s)?

If you maximize a window they seem to know how big to become, but when you make a window that has @desktowidth // height as its size its fullscreen basically.

I could just subtract the width of the two, but I've done that before and it doesn't work right on someone elses computer (It's not dynamic)

There should be a way :)

I saw the helpfile mentioning WinGetClientSize("Program Manager"), but it still returns 1280x1024 (It should be around 1120x1000...ish)

kthx

A rather crude method would be to create a hidden window that has been maximised and then get the size of it. But like I said, that is crude. I'm pretty sure there is a better way somewhere. Have you tried searching the forums?
Link to comment
Share on other sites

I've searched for this before too though. Usually finding a simple question can be harder than finding a more difficult one, though...

I have a hard time finding what I'm searching for on these forums though. Especially when it something that wouldn't be very common. At least, I don't think this would be.

Not to mention I just suck at searching here, lol.

~Example, it took me nearly an hour to find that "Wake On Lan" script because I didn't know what keywords to use. That was awhile ago... quite awhile ago...

Oh, and Ill just use the hidden window idea for now, but if theres an easier way it'd be nice to know.

Edited by Rad
Link to comment
Share on other sites

Is there any way to get the width/height of the actual desktop, excluding the taskbar and sidebar(s)?

If you maximize a window they seem to know how big to become, but when you make a window that has @desktowidth // height as its size its fullscreen basically.

I could just subtract the width of the two, but I've done that before and it doesn't work right on someone elses computer (It's not dynamic)

There should be a way :)

I saw the helpfile mentioning WinGetClientSize("Program Manager"), but it still returns 1280x1024 (It should be around 1120x1000...ish)

kthx

You were close just using wrong command WinGetPos returns the width and hight. WinGetClientSize returns client size

$DeskSize = WinGetPos("Program Manager")

MsgBox(0, "Size", "The Desktop is Width:"&$DeskSize[2]&" Hight:"&$DeskSize[3])

Link to comment
Share on other sites

You were close just using wrong command WinGetPos returns the width and hight. WinGetClientSize returns client size

$DeskSize = WinGetPos("Program Manager")

MsgBox(0, "Size", "The Desktop is Width:"&$DeskSize[2]&" Hight:"&$DeskSize[3])

If you have a task bar at the top of your screen then the DeskSize[1] value will still be 0, and if you have a task bar at the left of your screen then DeskSIze[0] will still be 0.

If this matters then the following method posted by Siao is the way to go

;===============================================================================
;
; Function Name:    _GetWorkingArea()
; Description:    Returns the coordinates of desktop working area rectangle
; Parameter(s):  None
; Return Value(s):  On Success - Array containing coordinates:
;                       $a[0] = left
;                       $a[1] = top
;                       $a[2] = right
;                       $a[3] = bottom
;                  On Failure - 0
;
;===============================================================================
Func _GetWorkingArea()
#cs
BOOL WINAPI SystemParametersInfo(UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni);
uiAction SPI_GETWORKAREA = 48
#ce
    Local $dRECT = DllStructCreate("long; long; long; long")
    Local $spiRet = DllCall("User32.dll", "int", "SystemParametersInfo", _
                        "uint", 48, "uint", 0, "ptr", DllStructGetPtr($dRECT), "uint", 0)
    If @error Then Return 0
    If $spiRet[0] = 0 Then Return 0
    Local $aRet[4] = [DllStructGetData($dRECT, 1), DllStructGetData($dRECT, 2), DllStructGetData($dRECT, 3), DllStructGetData($dRECT, 4)]
    Return $aRet
EndFunc
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Yes, that's probably the way to go :)

Note that it also takes into acount all docked toolbars that have "always on top" turned on. Also it will ignore taskbar if it has "auto hide" turned on.

Edited by Siao

"be smart, drink your wine"

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...