Jump to content

desktopwidth/height


pomj
 Share

Recommended Posts

Heh, when I run that code, it tries to create a window with width/height of -4 x 716.

Sanders I know the code from post 11 will give you the wrong size (-4 x 716). Did you try the code from post 17?

I move the taskbar to the four sides of the screen and even resize the taskbar 3 times it size and work fine in my computer at work and home.

AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Link to comment
Share on other sites

  • 10 months later...

This worked better for me

based on Saunders' code above in post #20

Func _GetTaskbarSide()
    Local $h_Wnd, $a_Pos
    Local $i_WTMM = Opt("WinTitleMatchMode", 4)
    Local $v_Return = 0
    Do
        If @error Then
            SetError(1)
            ExitLoop
        EndIf
        $a_Pos=WinGetPos("[CLASS:Shell_TrayWnd]")
        If $a_Pos[0] = 0 AND $a_Pos[1] = 0 Then
            If $a_Pos[2] = @DesktopWidth Then
                $v_Return = 'Top'
            Else
                $v_Return = 'Left'
            EndIf
        ElseIf $a_Pos[3] = @DesktopHeight Then
            $v_Return = 'Right'
        Else
            $v_Return = 'Bottom'
        EndIf
    Until True
    Opt('WinTitleMatchMode', $i_WTMM)
    Return $v_Return
EndFunc

MsgBox(1,"Taskbar Position",_GetTaskbarSide())

thanks @Saunders

Link to comment
Share on other sites

Hi, I'm a newbie to autoit programming so I aplogize if I have missed something obvious.

I'm trying to implement some window managing functions I've come to appreciate while using larswm in linux and I wonder how I get the "real" desktop workarea. I tried @DesktopWidth and @DesktopHeight but these macros seems to ignore the taskbar.

cheers

/michael

The function below uses the Win API will return the limits of the user working area of the desktop taking into account the taskbar and any other desktop toolbars.

#include <WinApi.au3>
Global $WorkArea = _GetWorkArea()
If IsArray($WorkArea) Then
    MsgBox(0, "Desktop Working Area","Left = " & _ 
    $WorkArea[0] & @CRLF & "Top = " & _ 
    $WorkArea[1] & @CRLF & "Right = " & _ 
    $WorkArea[2] & @CRLF & "Bottom = " & _ 
    $WorkArea[3])
Else
    MsgBox(0, "Desktop Working Area","Faild to get Desktop work area")
EndIf

Func _GetWorkArea()
Local Const $SPI_GETWORKAREA = 48
Local $rect[4]
Local $stRect = DllStructCreate("long left;long top;long right;long bottom")
Local $iResult = _WinAPI_SystemParametersInfo($SPI_GETWORKAREA, 0, DllStructGetPtr($stRect), 0)
    If $iResult = True Then
        $rect[0] = DllStructGetData($stRect,"left")
        $rect[1] = DllStructGetData($stRect,"top")
        $rect[2] = DllStructGetData($stRect,"right")
        $rect[3] = DllStructGetData($stRect,"bottom")
        Return $rect
    Else
        Return 0
    EndIf
EndFunc

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Link to comment
Share on other sites

  • 8 months later...

I wonder if there's a way to find out the location and size of the taskbar because in every version of

Windows I've tried, if you have Always On Top for the Taskbar set to False, then GetWorkArea will

return the screen resolution. I always set Always On Top to False so that the Title bar won't get

trapped under the Taskbar if for some strange reason I should have it at the top of the screen

(or it decides to go there by itself.)

In such cases GetWorkArea is tantamount to using @DesktopHeight and @DesktopWidth

Link to comment
Share on other sites

Hi pomj,

Please create descriptive topics.

Using one word topics makes it really difficult to use the search feature, and those that could probably answer your question will probably not even read your thread.

Doing it enough could cause your posting privileges to be taken away all together, and we don't want that :P .

Thanks.

Link to comment
Share on other sites

i was under the impression that @DesktopWidth and @DesktopHeight are only of the primary monitor. If multiple monitors are used the @Desktop... macros only show the primary monitor's desktop size.

$FullScreenW = DllCall("user32.dll", "int", "GetSystemMetrics", "int", $SM_CXVIRTUALSCREEN)
$FullScreenH = DllCall("user32.dll", "int", "GetSystemMetrics", "int", $SM_CYVIRTUALSCREEN)

http://msdn.microsoft.com/en-us/library/ms724385.aspx

Link to comment
Share on other sites

I wonder if there's a way to find out the location and size of the taskbar because in every version of

Windows I've tried, if you have Always On Top for the Taskbar set to False, then GetWorkArea will

return the screen resolution. I always set Always On Top to False so that the Title bar won't get

trapped under the Taskbar if for some strange reason I should have it at the top of the screen

(or it decides to go there by itself.)

In such cases GetWorkArea is tantamount to using @DesktopHeight and @DesktopWidth

@MilesAhead

please delete your extra posts caused by the forum server service disruption.

(not just the 8AM GMT daily backup when the forum goes offline momentarily, but now at peak usage times!)

searching or posting a new topic is preferred to reviving old topics.

use WinGetPos() as shown in above posts by Saunders and kamil.

works with taskbar topmost or not.

a search of the forum for "taskbar height" brings up topics with this code

$aTray = WinGetPos("[CLASS:Shell_TrayWnd]") ; taskbar size and position on desktop
    For $i = 0 To UBound($aTray) -1
        ConsoleWrite("+> $aTray[" & $i & "]: "& $aTray[$i] & @CRLF)
    Next

I see fascists...

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...