Jump to content

GUI Position on different Resolutions


Recommended Posts

Hi guys.

I want to create a small GUI that shows in the bottom right of the screen, just above the systems tray. The following code does this on my laptop:

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$GUI = GUICreate("Test", 259, 83, 1006, 640)
$Text = GUICtrlCreateLabel("Test", 88, 24, 58, 36)
GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

When this is run on a different resolution the GUI is out of place - obviously due to specifying the position the GUI is set to appear. Anybody know what I need to do to get this to appear in the correct place no matter of the resolution? I guess I need to specify where to place the gui in relation to the res, but not sure from there :unsure:

Thanks in advance,

3mgb

Link to comment
Share on other sites

  • Moderators

3mustgetbeers,

Use the @DesktopWidth and @DesktopHeight macros to determine the resolution - then position your GUI relative to those values: :unsure:

$GUI = GUICreate("Test", 259, 83, @DesktopWidth - 260, @DesktopHeight - 105)

Of course, you will need to adjust the values to get it exactly where you want. :>

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:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Try this:

#include <Array.au3>
#include <GUIConstantsEx.au3>
$aTaskbar = WinGetPos("[CLASS:Shell_TrayWnd]", "")
$GUI = GUICreate("Test", 259, 83, @DesktopWidth, @DesktopHeight)
$Text = GUICtrlCreateLabel("Test", 88, 24, 58, 36)
GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
$aWin = WinGetPos($GUI)
WinMove($GUI, "", @DesktopWidth - $aWin[2] - 4, @DesktopHeight - $aWin[3] - $aTaskbar[3] - 4)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Tested on Win7 x64.

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Just look in the help file: http://www.autoitscript.com/autoit3/docs/functions/WinGetPos.htm

It is the width of the window. I tried to calculate the height of the taskbar, width and height of the windows and finally a little calculation to place the window to the right bottom just above the taskbar.

Br,

UEZ

PS: I update the code.

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

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