Sign in to follow this  
Followers 0
ZetupEXE

Get Gui ONTOP State?

5 posts in this topic

Hi there,

i am just on step ahead to finish my little project, but now i am struggling for two weeks now with a annoying problem.

So i hope you guys can help me out a last time?! :graduated:

The description of my problem is quite short:

How can i find out whether my GUI is over all other Windows?

i would like to thank all of you for your great help.

cu..

Zetup-EXE

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi there,

i am just on step ahead to finish my little project, but now i am struggling for two weeks now with a annoying problem.

So i hope you guys can help me out a last time?! :graduated:

The description of my problem is quite short:

How can i find out whether my GUI is over all other Windows?

i would like to thank all of you for your great help.

cu..

Zetup-EXE

The position of a window is given by its Z-order. The easiest way I know of with Autoit is the use WinList function. The first window in the list is the topmost window (Same as the order of applications shown when you press Alt TAB). So if your window is the first in the list of visible windows it's on top of all others. Edited by martin

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.

Share this post


Link to post
Share on other sites

@martin: thanks for your tip. u'r tip solved my problem and so my project finished as version 1.0

i did the following to get the "guiontop"-state:

If WinGetTitle($osName) = WinGetTitle("[active]") Then

....

EndIf

thx.

Zetup-EXE

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Topmost property is defined by the ExStyle $WS_EX_TOPMOST and can be determined with _WinAPI_GetWindowLong().

#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

GUICreate("My TOPMOST GUI #1", Default, Default, Default, Default, Default, $WS_EX_TOPMOST)
GUISetState(@SW_SHOW)

$hwnd = GUICreate("My TOPMOST GUI #2")
GUISetState(@SW_SHOW)
WinSetOnTop($hwnd,"",1)

$var = WinList()
For $i = 1 To $var[0][0]
    ; Only display visble windows that have a title
    If $var[$i][0] <> "" And IsVisible($var[$i][1]) Then
        ConsoleWrite("Title=" & $var[$i][0] & @TAB & "Handle=" & $var[$i][1] & @TAB & "IsTopmost=" & BitAND(_WinAPI_GetWindowLong($var[$i][1], $GWL_EXSTYLE), $WS_EX_TOPMOST) & @CRLF)
    EndIf
Next

While 1
    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
GUIDelete()

Func IsVisible($handle)
    If BitAND(WinGetState($handle), 2) Then
        Return 1
    Else
        Return 0
    EndIf
EndFunc   ;==>IsVisible

Edit: Added WinSetOnTop() example.

Edited by KaFu
1 person likes this

Share this post


Link to post
Share on other sites

Topmost property is defined by the ExStyle $WS_EX_TOPMOST and can be determined with _WinAPI_GetWindowLong().

#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

GUICreate("My TOPMOST GUI #1", Default, Default, Default, Default, Default, $WS_EX_TOPMOST)
GUISetState(@SW_SHOW)

$hwnd = GUICreate("My TOPMOST GUI #2")
GUISetState(@SW_SHOW)
WinSetOnTop($hwnd,"",1)

$var = WinList()
For $i = 1 To $var[0][0]
    ; Only display visble windows that have a title
    If $var[$i][0] <> "" And IsVisible($var[$i][1]) Then
        ConsoleWrite("Title=" & $var[$i][0] & @TAB & "Handle=" & $var[$i][1] & @TAB & "IsTopmost=" & BitAND(_WinAPI_GetWindowLong($var[$i][1], $GWL_EXSTYLE), $WS_EX_TOPMOST) & @CRLF)
    EndIf
Next

While 1
    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
WEnd
GUIDelete()

Func IsVisible($handle)
    If BitAND(WinGetState($handle), 2) Then
        Return 1
    Else
        Return 0
    EndIf
EndFunc   ;==>IsVisible

Edit: Added WinSetOnTop() example.

That doesn't tell you which window is on top of all others though.

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.

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  
Followers 0