Search code examples
user-interfaceautohotkeycoordinate-systems

Cover inactive windows with GUI, Solutions to Variable Coordinates (AHK)


I collapse all my windows to title bars when not active. I want to cover these inactive windows with different color GUIs. The GUI will only need minimal functionality, just a way to color-code title bars when collapsed, and inactive. That way, I can tell what's what much easier when I look at a desktop full of title bars.

Although I know I have the correct coordinates stored as variables, the gui doesn't show up at all if I specify coordinates as numbers, or as variables. But if I don't specify any coordinates, the GUI appears in the middle of the screen.

This just seems like a combination of

-settimer, and a timer that updates the coordinates when the window moves.

-alwaysontop(ish) of a specific window for each gui(could use some help here, Looking to apply winset, top to a GUI when it's associated window is inactive, but also remain under any newly active window (to keep the GUI visible when looking at the desktop).

-using the corresponding window's y coordinate to know how high to place the GUI(main issue, although I know I have the correct coordinates stored as variables)

-displaying a different color for each GUI.

-The GUI should span across the entire screen width, and be 1/17 the screen height (about the height of the title bar with my screen/resolution).

-winhide a window's gui when it's associated window is active, and winshow when inactive

    #SingleInstance,Force
    WinGetPos , X_SciTEWindow, Y_SciTEWindow, Width_SciTEWindow, Height_SciTEWindow, ahk_class SciTEWindow ;I don't even need the X_SciTEWindow, because the bars will all be aligned at x0, but it's there... 
    SysGet, aScreenHeight, 1 
    bar_height := Round(aScreenHeight / 17)
    Gui, Color, aqua,FFB1B1
    Gui, Show, w%A_ScreenWidth% h%bar_height%, SomeStupidBar
    WinSet, Style,  -20xC40000
    Winmove, %SomeStupidBar%,  x0, y%Y_SciTEWindow%, w%A_ScreenWidth%, h%bar_height%
    MsgBox, Time to move the window to x0, y%Y_SciTEWindow%, w%A_ScreenWidth%, h%bar_height%
    Winmove, %SomeStupidBar%,  x0, y%Y_SciTEWindow%, w%A_ScreenWidth%, h%bar_height%
    return
    Esc::ExitApp


    SetTimer, ShowGui, 500
    ShowGui:    
    IfWinNotExist, ahk_class AutohotkeyGUI
    {
    Gui, +Owner%WinID% +Border +ToolWindow 
    Gui, Show, NoActivate x%X% y%Y% w51 h431, %GuiTitle%
    }
    else
    {
    WinWaitActive, ahk_class SciTEWindow
    WinGetPos, X_SciTEWindow, Y_SciTEWindow,,, ahk_class Notepad
    WinGet, WinID, ID, ahk_class SciTEWindow,,,
    IfWinNotExist, ahk_class AutohotkeyGUI
    WinGetPos, %SomeStupidBar%, , , ,  ahk_class AutohotkeyGUI
    If %SomeStupidBar%<>X - 56
    WinMove, ahk_class AutohotkeyGUI,  X - 56
    }
    return

Any help would be greatly appreciated.


Solution

  • #NoEnv
    #SingleInstance Force
    
    Gui, SciTE: +Owner -Caption
    Gui, SciTE: Color, aqua 
    
    Gui, Notepad: +Owner -Caption
    Gui, Notepad: Color, red
    
    SysGet, aScreenHeight, 1 
    bar_height := Round(aScreenHeight / 17)
    
    SetTimer, ShowGui, 500
    return
    
    Esc::ExitApp
    
    ShowGui:
    If !WinExist("ahk_class SciTEWindow") ; means "NOT"
        Gui, SciTE: Cancel
    else
    {
        WinGetPos, X_SciTE, Y_SciTE,,, ahk_class SciTEWindow
        If X_SciTE >= 0
        Gui, SciTE:  Show, NoActivate x%X_SciTE% y%Y_SciTE% w51 h%bar_height%, SciTEWindow
    }
    If !WinExist("ahk_class Notepad")
        Gui, Notepad: Cancel
    else
    {
        WinGetPos, X_Notepad, Y_Notepad,,, ahk_class Notepad
        If X_Notepad >= 0
        Gui, Notepad:  Show, NoActivate x%X_Notepad% y%Y_Notepad% w51 h%bar_height%, Notepad
    }
    return
    
    #If WinActive("ahk_class AutoHotkeyGUI")
    
        ~*LButton Up::
            WinGetTitle, ActiveTitle, A         
            WinActivate, ahk_class %ActiveTitle%    
        return
    
    #If