Jump to content
Sign in to follow this  
CrewXp

Any way to makea gui on top, but not on top of the taskbar?

Recommended Posts

CrewXp

Hey, quick question. Is there any way to make a gui overlap anything but the taskbar? I'm trying to make a tray notify, but it gets stuck behind windows/apps. So I added the alwaysontop attribute to it, but now it overlaps even the taskbar.

Is there any way around this?

Possibilties I see

1.) Somehow make the taskbar always on top. (Ghetto way around it..)

2.) Apply some _ALMOST_Always_On_Top attribute to my GUI to get it to stay behind the gui.

Example Code for Tray Popup

#include <WindowsConstants.au3>
#Include <WinAPI.au3>

; Create Toast window
Global $hGUI = GUICreate("", 200, 100, @DesktopWidth - 210, @DesktopHeight - 130, $WS_POPUPWINDOW, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST)
Global $hLabel = GUICtrlCreateLabel("Click to close", 1, 1, 198, 198)

; Slide in Toast - but keep focus on current window
_WinAnimate($hGUI, 0x00040008)
$hCurrWnd = _WinAPI_GetForegroundWindow()
GUISetState(@SW_SHOW, $hGUI)
WinActivate($hCurrWnd, "")

; Wait for click from Toast
While 1
    
    Local $aMsg = GUIGetMsg(1)

    If $aMsg[1] = $hGUI And $aMsg[0] = $hLabel Then ExitLoop
    
WEnd

; Slide out window
_WinAnimate($hGUI, 0x00050004)

Exit

; --------------

; Gary Frost's WinAnimate function

Func _WinAnimate($h_gui, $i_mode, $i_duration = 1000)
    
    If @OSVersion = "WIN_XP" OR @OSVersion = "WIN_2000" Or @OSVersion = "WIN_VISTA" Then
        
        DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $h_gui, "int", $i_duration, "long", $i_mode)
        
        Local $ai_gle = DllCall('kernel32.dll', 'int', 'GetLastError')
        If $ai_gle[0] <> 0 Then
            Return SetError(1, 0, 0)
        EndIf
        Return 1
        
    Else
        
        Return SetError(2, 0, 0)
        
    EndIf
EndFunc;==> _WinAnimate()

Share this post


Link to post
Share on other sites
Yashied

#include <GUIConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <WinAPI.au3>

; Create Toast window
$hGUI = GUICreate("", 200, 100, @DesktopWidth - 210, @DesktopHeight - 130, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST)
GUICtrlCreateLabel("", 0, 0, 200, 100)
GUICtrlSetBkColor(-1, 0x000000)
GUICtrlSetState(-1, $GUI_DISABLE)
$hLabel = GUICtrlCreateLabel("Click to close", 1, 1, 198, 99)

_WinAnimate($hGUI, 0x00040008)
GUISetState(@SW_SHOWNOACTIVATE)

; Wait for click from Toast
While 1
    
    Local $aMsg = GUIGetMsg(1)

    If $aMsg[1] = $hGUI And $aMsg[0] = $hLabel Then ExitLoop
    
WEnd

; Slide out window
_WinAnimate($hGUI, 0x00050004)

Exit

; --------------

; Gary Frost's WinAnimate function

Func _WinAnimate($h_gui, $i_mode, $i_duration = 1000)
    
    If @OSVersion = "WIN_XP" OR @OSVersion = "WIN_2000" Or @OSVersion = "WIN_VISTA" Then
        
        DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $h_gui, "int", $i_duration, "long", $i_mode)
        
        Local $ai_gle = DllCall('kernel32.dll', 'int', 'GetLastError')
        If $ai_gle[0] <> 0 Then
            Return SetError(1, 0, 0)
        EndIf
        Return 1
        
    Else
        
        Return SetError(2, 0, 0)
        
    EndIf
EndFunc;==> _WinAnimate()

EDIT:

And look at WinAPIEx.au3

Edited by Yashied

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  

×