Jump to content

Recommended Posts

Posted

Hi there!

I'm looking for a way to position my gui above the taskbar,

I already have it located in the lower right corner using @DesktopHeight & @DesktopHeight.

But my client is exactly above the taskbar while at a friends computer it positions itself a bit underneath the taskbar which makes some buttons unfunctional.

 

How can I retreive the taskbar size?

 

Thank you in advance!

  • Moderators
Posted

Skorm92,

Look in my Toast UDF - the _Toast_Locate function shows how I determine the taskbar position and location by getting the available workarea size via a SystemParametersInfoW call. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

  Reveal hidden contents

 

Posted
  On 11/19/2014 at 5:35 PM, jguinch said:

Post your code...

Why do you need my code, Within my question there is nothing that requires you to review my code.

I used a blank file to test the above posted codes..

Melba23,

I will look into it! Thank you.

Posted

I've been looking into your UDF, Although I can see toast_locate I can't really seem to find the exact command that reads the taskbar size/position

Posted

From Melba's Toast UDF :

#Include <Array.au3> ; just for _ArrayDiplay

If @AutoItVersion < "3.3.8.0" Then
    $tWorkArea = DllStructCreate("long Left;long Top;long Right;long Bottom")
Else
    $tWorkArea = DllStructCreate("struct;long Left;long Top;long Right;long Bottom;endstruct")
EndIf

DllCall("user32.dll", "bool", "SystemParametersInfoW", "uint", 48, "uint", 0, "ptr", DllStructGetPtr($tWorkArea), "uint", 0)
If @error Then Return SetError(2, 0, -1)
Local $aWorkArea[4] = [DllStructGetData($tWorkArea, "Left"), DllStructGetData($tWorkArea, "Top"), _
        DllStructGetData($tWorkArea, "Right"), DllStructGetData($tWorkArea, "Bottom")]

_ArrayDisplay($aWorkArea)
Posted

Same idea...

$hGui = GuiCreate("test")
GuiSetState()

$WorkAera = _GetWorkArea()
WinMove($hGui, "", $WorkAera[0], $WorkAera[1], $WorkAera[4], $WorkAera[5])

While GUIGetMsg() <> -3
WEnd

Func _GetWorkArea()
    Local $Area[6]
    Local $StartRect = DllStructCreate("int[4]")
    Local $PStartRect = DllStructGetPtr($StartRect)
    DllCall("user32.dll", "int", "SystemParametersInfo", "int", 48, "int", 0, "ptr", $PStartRect, "int", 0)
    $Area[0] = DllStructGetData($StartRect,1,1)
    $Area[1] = DllStructGetData($StartRect,1,2)
    $Area[2] = DllStructGetData($StartRect,1,3)
    $Area[3] = DllStructGetData($StartRect,1,4)
    $Area[4] = $Area[2] - $Area[0]
    $Area[5] = $Area[3] - $Area[1]
    Return $Area
EndFunc
  • 3 years later...
Posted (edited)

Currently AutoIt has:
 

_WinAPI_GetWorkArea()

But ....

@mikell I was working a little with your example, as following:

; #FUNCTION# ====================================================================================================================
; Name ..........: _Monitor_GetWorkArea
; Description ...:
; Syntax ........: _Monitor_GetWorkArea()
; Parameters ....: $iDPI                - [optional] an integer value. Default is -1.
; Return values .: Array
; Author ........: mikell
; Modified ......: mLipok
; Remarks .......: HowTO: WinMove($hGui, "", $aWorkAera[0], $aWorkAera[1], $aWorkAera[4], $aWorkAera[5])
; Related .......:
; Link ..........: http://www.autoitscript.com/forum/topic/165766-gui-position-minus-taskbar-height/#entry1210698
; Link ..........: https://docs.microsoft.com/pl-pl/windows/desktop/api/winuser/nf-winuser-systemparametersinfofordpi
; Link ..........: https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-systemparametersinfoa
; Example .......: No
; ===============================================================================================================================
Func _Monitor_GetWorkArea($iDPI = -1)
    Local $tStartRect = DllStructCreate("int[4]")
    Local $pStartRect = DllStructGetPtr($tStartRect)
    If $iDPI = -1 Then
        DllCall("user32.dll", "int", "SystemParametersInfo", "int", $SPI_Monitor_GetWorkArea, "int", 0, "ptr", $pStartRect, "int", 0)
    Else
        DllCall("user32.dll", "int", "SystemParametersInfoForDpi", "int", $SPI_Monitor_GetWorkArea, "int", 0, "ptr", $pStartRect, "int", 0, "int", $iDPI)
    EndIf

    Local $aArea[6]
    $aArea[0] = DllStructGetData($tStartRect, 1, 1)
    $aArea[1] = DllStructGetData($tStartRect, 1, 2)
    $aArea[2] = DllStructGetData($tStartRect, 1, 3)
    $aArea[3] = DllStructGetData($tStartRect, 1, 4)
    $aArea[4] = $aArea[2] - $aArea[0]
    $aArea[5] = $aArea[3] - $aArea[1]
    Return $aArea
EndFunc   ;==>_Monitor_GetWorkArea


I just add support for DPI but not tested yet, and reading here:
https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-systemparametersinfoa

  Quote
SPI_GETWORKAREA
0x0030
Retrieves the size of the work area on the primary display monitor. The work area is the portion of the screen not obscured by the system taskbar or by application desktop toolbars. The pvParam parameter must point to a RECT structure that receives the coordinates of the work area, expressed in physical pixel size. Any DPI virtualization mode of the caller has no effect on this output.

To get the work area of a monitor other than the primary display monitor, call the GetMonitorInfo function.

Expand  

I was wondering how to combine GetMonitorInfo with GetWorkArea ?

I'm trying to combine it all together with:

 

Do you have idea how to combine GetMonitorInfo with GetWorkArea ?

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

This is what i use

#include <Inet.au3>
#include <Misc.au3>
#include <Timers.au3>
#include <WinAPI.au3>
#include <Marquee.au3>
#include <Constants.au3>
#include <WinAPIFiles.au3>
#include <FileConstants.au3>
#include <ScreenCapture.au3>
#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <StructureConstants.au3>
#include <WinAPIsysinfoConstants.au3>
#include <WinAPISys.au3>
#include <WinAPIMisc.au3>
#include <APISysConstants.au3>

$GWArea = GetWorkArea()

$hChildWin = GUICreate("window", @DesktopWidth, $GWArea[0] , -1, -1, $WS_POPUP)
GUISetState(@SW_SHOW, $hChildWin)
Sleep(3000)
Exit

Func GetWorkArea()
    Local $tWorkArea = DllStructCreate($tagRECT)
    _WinAPI_SystemParametersInfo($SPI_GETWORKAREA, 0, $tWorkArea)
    Local $aReturn = [DllStructGetData($tWorkArea, 'Bottom') - DllStructGetData($tWorkArea, 'Top')]
    Return $aReturn
EndFunc   ;==>GetWorkArea

Nevermind the includes, it's just a copy paste i do to make sure it doesnt complain.

  Reveal hidden contents

IUIAutomation - Topic with framework and examples

Au3Record.exe

Posted (edited)
  On 10/11/2018 at 4:45 PM, mikell said:

_WinAPI_GetMonitorInfo returns an array, isn't the $array[1] what you're looking for ?  :)

Expand  

Yes.... this is it ..... almost... I'm working on.

 

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Here is one of the results of my work:

#include <WinAPIGdi.au3>

_Example()

Func _Example()
    Local $hWindow = WinGetHandle("[REGEXPTITLE:(?i)(.*" & @ScriptName & ".*SciTE.*?)]")
    Local $hMonitor = _WinAPI_MonitorFromWindow($hWindow, $MONITOR_DEFAULTTONULL)
    ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hMonitor = ' & $hMonitor & @CRLF & '>Error code: ' & @error & '    Extended code: 0x' & Hex(@extended) & @CRLF) ;### Debug Console

    Local $aData = _WinAPI_GetMonitorInfo($hMonitor)
    If Not @error Then
        ConsoleWrite('Handle:      ' & $hMonitor & @CRLF)
        ConsoleWrite('Rectangle:   ' & DllStructGetData($aData[0], 1) & ', ' & DllStructGetData($aData[0], 2) & ', ' & DllStructGetData($aData[0], 3) & ', ' & DllStructGetData($aData[0], 4) & @CRLF)
        ConsoleWrite('Work area:   ' & DllStructGetData($aData[1], 1) & ', ' & DllStructGetData($aData[1], 2) & ', ' & DllStructGetData($aData[1], 3) & ', ' & DllStructGetData($aData[1], 4) & @CRLF)
        ConsoleWrite('Primary:     ' & $aData[2] & @CRLF)
        ConsoleWrite('Device name: ' & $aData[3] & @CRLF)
    EndIf
EndFunc   ;==>_Example

 

Already added to HelpFile - should be available along with one of the future versions of AutoIt.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Better yet use Shell_TrayWnd with $MONITOR_DEFAULTTONEAREST if you cannot know for sure on which monitor the user has set the task bar ..

As to DPI Scaling (future wise) I think it should fit in to the AutoItSetOption category if and when someone gets about and around doing it .. :

https://blogs.windows.com/buildingapps/2017/04/04/high-dpi-scaling-improvements-desktop-applications-windows-10-creators-update/
 

Deye

Posted
  On 10/12/2018 at 7:54 PM, Deye said:

Better yet use Shell_TrayWnd with $MONITOR_DEFAULTTONEAREST if you cannot know for sure on which monitor the user has set the task bar

Expand  

I have dual monitor with dual TaskBar :) and I need to know working area for window on specyfic monitor.

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

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
  • Recently Browsing   0 members

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