Jump to content
Sign in to follow this  

check if screen X/Y position is available

Recommended Posts


I've added this part to my script to check (when you exit the script) if you have changed the location of the app on the screen and i save it to an ini file :

If @Compiled = 1 Then
    WinActivate($DigiAD, "")
    Local $Handle   =   WinGetHandle($DigiAD, "")
    $RFScreenPos    =   WinGetPos($Handle, "")
    If Not FileExists ($AppDataDir) Then DirCreate ($AppDataDir)
    IniWrite($DigiAD_INI, "PosX", "value", $RFScreenPos[0])
    IniWrite($DigiAD_INI, "PosY", "value", $RFScreenPos[1])


$DigiAD is the handle of the GUI

$AppDataDir is the location where the ini-file gets saved

$DigiAD_INI is $AppDataDir + ini file name

when I open my script it reads these values and places the GUI at the specified location on the screen.

but what happens when you had 2 screens, you placed the app on the second screen, remove the second screen and then start the app again... would the GUI open outside of the visible area of the screen or would it just place it on the default location if the X or Y position is "out of reach"?

Is there a way to check if the total screen resolution is smaller or bigger than the PosX or PosY?

this is how I create the GUI :

If FileExists ($DigiAD_INI) And @Compiled = 1 Then
    $DigiAD =   GUICreate ("Digipolis Active Directory tool", 900, 700, IniRead ($DigiAD_INI, "PosX", "value", 0), IniRead ($DigiAD_INI, "PosY", "value", 0))
    $DigiAD =   GUICreate ("Digipolis Active Directory tool", 900, 700)

I can't test that here.

Edited by colombeen

Share this post

Link to post
Share on other sites

You can get the desktop position and size with WinGetPos("[TITLE:Program Manager; CLASS:Progman]"), and the test if your coords are in the range :

$aDesktopPos = WinGetPos("[TITLE:Program Manager; CLASS:Progman]")

If $posX < $aDesktopPos[0] OR $posX > $aDesktopPos[0] + $aDesktopPos[2] OR $posY < $aDesktopPos[1] OR $posY > $aDesktopPos[1] + $aDesktopPos[3] Then
    $posX = Default
    $posY = Default

Share this post

Link to post
Share on other sites

Hi jguinch

my posX and posY values are the values that you just retrieved with $aDesktopPos. that's not the issue. My problem is that I can't find a way to see if the X and Y positions are within the total screen resolution because i don't know how to see the total screen resolution when you have more then one screen.

Share this post

Link to post
Share on other sites

I've 3 screens with a overall reolution of 4960x1050 px.

#include <Array.au3>

$hFullScreen = WinGetHandle("[TITLE:Program Manager;CLASS:Progman]")
$aFullScreen = WinGetPos($hFullScreen)
ConsoleWrite(@DesktopWidth & "x" & @DesktopHeight & @CRLF)

Row|Col 0

That means when the GUI pos is < -gui width or > @desktopwidth or < -gui height or > @desktopheight that the GUI is not on your main screen.



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!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post

Link to post
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
Sign in to follow this  

  • Create New...