Jump to content

Recommended Posts

Posted (edited)

Hi,

I've searched but can only find posts from people with the opposite problem (asking how to get their GUI to display on top of a full-screen app, usually a game.

I've created a toolbar which I use in a work environment, creating the GUI with the following styles;

$hwnd = GUICreate($title, $toolbarWidth, $height, $left, $top, $WS_POPUPWINDOW, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST))
 
I want it to have a TOPMOST style as it's supposed to behave like the Windows taskbar (which it does in all but one scenario).
 
If I start a full-screen RDP session, I can still see my toolbar and have to close it.  Is there a way I can make it appear on top of all windows *except* full-screen apps (in the same way the taskbar allows full-screen apps on top of it)?
 
Thanks in advance.
 
Val.
Edited by Valiante
Posted

I would just check if the active window fills the screen, and if it does, turn off on top of your toolbar.

I would do it like so: >link to topic.

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Posted

Or you can get the handle to your toolbar and check it with WinGetState(), this will tell you if the application is maximized as well.

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Posted

Thanks for your replies.  I could indeed introduce a loop to check for an active full-screen window, but I was hoping for a style constant (or combination thereof) which might do the trick and order it behind full-screen windows natively, much like the taskbar.

I'm not concerned about maximized windows as I'm using a combination of DllStructCreate and DllCall to leverage the SHAppBarMessage shell function and register my toolbar as an appbar, so its position and dimensions are respected in much the same way as the taskbar, and windows maximize up to it, not over it.

The only issue I've yet to overcome is full-screen windows.  Your suggestion is valid, I'm just hoping for something a little more elegant.

  • Moderators
Posted (edited)

What happens if you do:

WinSetOnTop($hwnd, "", 1)

Edit:

Sorry, I misread your request.  Indeed you could use WinSetOnTop() more than likely, but you'd have to verify (In a loop) what to look for.  There's no "conditional" constant you can put in the creation of a GUI.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted (edited)

Would that not just set my toolbar to the topmost window, in the same way the extended styles are on creation?

EDIT: Just to test the theory, I removed the $WS_EX_TOPMOST extended-style from my GUICreate line and added your line below.  The toolbar remains on top of all windows, including full-screen windows, so the behaviour is the same.

Rgds,

Val.

Edited by Valiante
  • Moderators
Posted (edited)

Indeed it would, like I said, I misread your initial request.  But like I said, without a checking the state of the active window, you cannot manage your issue correctly.

I've no idea if this will work or not, I do not have a full screen window to popup nor do I feel the urge to create one.

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

Global $ghWnd = GUICreate("", 100, 30, 0, 0, $WS_POPUPWINDOW, $WS_EX_TOOLWINDOW)
WinSetState($ghWnd, "", 1)
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
    _myWinOnTopIfFullSizeWin($ghWnd, False)
WEnd


Func _myWinOnTopIfFullSizeWin($hWndOnTop, $bOnTop = True)

    Local Const $iWidth = @DesktopWidth
    Local Const $iHeight = @DesktopHeight

    Local $hActive = WinActive("[ACTIVE]")
    If Not $hActive Then Return $hActive

    Local $aPos = WinGetPos($hActive)
    If Not IsArray($aPos) Then
        Return SetError(1, 0, 0)
    EndIf

    Local $iOnTop = 0

    If $aPos[0] <= 0 And $aPos[1] <= 0 And _
        $aPos[2] >= $iWidth And $aPos[3] >= $iHeight Then
        ; we have a full screen window
        $iOnTop = (($bOnTop) ? 1 : 0)
        WinSetState($hWndOnTop, "", $iOnTop)
        Return $hActive
    EndIf

    ; do the opposite if we're here of $bOnTop
    $iOnTop = (($bOnTop) ? 0 : 1)
    WinSetOnTop($hWndOnTop, "", $iOnTop)

    Return $hActive
EndFunc

.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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
×
×
  • Create New...