DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Last post Author Topic: [Compleet]: Auto replace icon in captionbar & taskbar  (Read 40,236 times)

skwire

  • I eat Coding Snacks for breakfast...
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,297
    • Participated in NANY Challenge Seventeen Times
    • Coding Snacks
    • Superboy Coder
    • Cody Award
    • Volunteers/Staff
    • Gathering Badge
Re: [Compleet]: Auto replace icon in captionbar & taskbar
« Reply #25 on: September 29, 2009, 03:54 AM »
Is it possible just to hide them, not remove them?

I suppose one could write code to watch the mouse cursor and, if it was in the titlebar area, set the window style back to +0x80000 to show the buttons again.

Is it possible just to hide some of them, e.g. leaving the close button only?

I don't think so, but I don't know for certain.

skwire

  • I eat Coding Snacks for breakfast...
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,297
    • Participated in NANY Challenge Seventeen Times
    • Coding Snacks
    • Superboy Coder
    • Cody Award
    • Volunteers/Staff
    • Gathering Badge
Re: [Compleet]: Auto replace icon in captionbar & taskbar
« Reply #26 on: September 29, 2009, 06:10 AM »
Here, try this.  When you start up this version, a message box will popup asking if you want to enable the min/max/close tweak.  If you choose yes, they will be hidden upon each window's creation and they should appear whenever your mouse is in the titlebar area.  It's not perfect but it seems to work fairly well.  Also, this version leaves the tray icon in place so you can exit it.  All min/max/close buttons should be restored on exit.

Code: (autoit)
/*
Author:  Jody Holmes (Skwire)
Date:    2009-08-23
Contact: skwire@skwire.net


v0.0.0.3 - 2009-09-29
    + Added optional showing/hiding of titlebar min/max/close buttons.

v0.0.0.2 - 2009-08-28
    * Hook now fires on two additional messages.
        HSHELL_REDRAW
        HSHELL_RUDEAPPACTIVATED

v0.0.0.1 - 2009-08-23
    + Initial build.

*/

;#NoTrayIcon
#Persistent
#NoEnv
#SingleInstance, Force
SetWorkingDir, %A_ScriptDir%
DetectHiddenWindows, Off
OnExit, Cleanup

Menu, Tray, NoStandard
Menu, Tray, Add, Exit, Cleanup

Gui +LastFound
hWnd := WinExist()

; Hook the shell.
; http://www.autohotkey.com/forum/viewtopic.php?p=123323#123323
DllCall( "RegisterShellHookWindow", UInt, hWnd )
MsgNum := DllCall( "RegisterWindowMessage", Str, "SHELLHOOK" )
OnMessage( MsgNum, "ShellMessage" )

; Create a blank cursor for use instead of a blank icon file.
; http://www.autohotkey.com/forum/viewtopic.php?p=220113#220113
VarSetCapacity( AndMask, 32*4, 0xFF ), VarSetCapacity( XorMask, 32*4, 0 )
hIcon := DllCall( "CreateCursor", Uint, 0, Int, 0, Int, 0, Int, 32, Int, 32, Uint, &AndMask, Uint, &XorMask )

; Initial loop to blank out existing windows.
WinGet, s, List
Loop, % s
{
    s := s%A_Index%
    ;SendMessage, 0x80, 0, hIcon, , % "ahk_id " . s
}

MsgBox, 36, TBarIconBlanker, Would you like to enable the min/max/close buttons tweak as well?
IfMsgBox, Yes
{
    MinMaxCloseOption := 1
    SetTimer, WatchCursor, 100
}

Return ; End of auto-execute section.


; ------------------------------------------------------------------------
; Subroutines ------------------------------------------------------------
; ------------------------------------------------------------------------

Cleanup:
{
    If ( MinMaxCloseOption = 1 ) ; Restore titlebar buttons on close.
    {
        WinGet, s, List
        Loop, % s
        {
            s := s%A_Index%
            WinSet, Style, +0x80000, % "ahk_id " . s ; Restore min/max/close buttons.
        }
    }
    ExitApp
}
Return


WatchCursor:
{
    MouseGetPos, , yPos, CurrID,
    If ( yPos >= 0 and yPos < 22 )
    {
        WinSet, Style, +0x80000, % "ahk_id " . CurrID ; Restore min/max/close buttons.
    }
    Else
    {
        WinSet, Style, -0x80000, % "ahk_id " . PrevID ; Get rid of min/max/close buttons.
        WinSet, Style, -0x80000, % "ahk_id " . CurrID ; Get rid of min/max/close buttons.
    }
}
Return


; ------------------------------------------------------------------------
; Functions --------------------------------------------------------------
; ------------------------------------------------------------------------

; Shell hook to blank out windows that are subsequently created.
ShellMessage( wParam, lParam )
{
    Global hIcon, MinMaxCloseOption, PrevID
    If wParam in 1,6,32772
    {
        SendMessage, 0x80, 0, hIcon, , % "ahk_id " . lParam ; Blank out titlebar and taskbar icons.
        If ( MinMaxCloseOption = 1 )
        {
            WinSet, Style, -0x80000, % "ahk_id " . lParam ; Get rid of min/max/close buttons.
        }
    }
    PrevID := lParam
}

tmpusr

  • Instantiation stuck in meatspace with no backup
  • Member
  • Joined in 2005
  • **
  • Posts: 154
Re: [Compleet]: Auto replace icon in captionbar & taskbar
« Reply #27 on: September 29, 2009, 09:42 AM »
Thanks. This is great.  :Thmbsup: I'll be running this on all my systems forever. :D

If only one could have the same for the Explorer toolbar buttons, the start button, the tray. A universal auto-hide for buttons and other UI elements - the minimalist's dream.

Can you make it not restore the window icon along with the buttons when hovering? It sometimes shows them, sometimes doesn't. I'd like to have an INI option for the behavior.

Can you restore the icon in the toolbar when hovering, either on the button or in toolbar area?

Can you make it work when hovering on background windows?

Can you blank out the window borders - make them transparent - in a similar fashion? If not blank out, then fill with some solid color. It would be neat to have borderless windows that only appear when hovering.

Can you blank out the right side of the Explorer statusbar (which, I just noticed, in Explorer menu is "Status Bar" which seems inconsistent with the way "Taskbar" is written), the part that has the unnecessary My Computer/Internet or simply fill it with a solid rectangle and remove it when hovering? The user would have to match the color and perhaps the height to the visual style - unless there are system variables for those that you can use.

Can you use a system variable to find out the actual height of the titlebar instead of the fixed value, 22? I use a larger title bar and it ony shows when I'm at the top 22.

Can you remove the empty space occupied by the invisible icon in front of the taskbar buttons?

I'd prefer it to ask nothing upon startup and default to hide buttons and have no tray icon.

Bug: Right clicking taskbar button doesn't bring up the menu (though sometimes it does).

Bug: Buttons not removed on command line window.

Bug-like behavior (due to implementation, if I'm correct): it keeps blinking with TeraCopy and 7-Zip, that update the % done in the titlebar.
« Last Edit: September 29, 2009, 11:21 AM by tmpusr »

skwire

  • I eat Coding Snacks for breakfast...
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,297
    • Participated in NANY Challenge Seventeen Times
    • Coding Snacks
    • Superboy Coder
    • Cody Award
    • Volunteers/Staff
    • Gathering Badge
Re: [Compleet]: Auto replace icon in captionbar & taskbar
« Reply #28 on: September 29, 2009, 11:46 AM »
This version checks the system for titlebar height so it should work better with your system.  It also attempts to keep the titlebar icon hidden when restoring the min/max/close buttons.  It also does away with the message box at the start and the tray icon.

As for your other requests, I really don't want to develop this app any further in all these other directions.  There are so many variables at play here and so many different system configurations that I simply have no desire to get knee-deep in trying to troubleshoot/fix/hack/whatever.  Feel free to study the code and take it further on your own.  There really isn't a whole lot of complex code in this script.  Here you go:

Code: (autoit)
/*
Author:  Jody Holmes (Skwire)
Date:    2009-08-23
Contact: skwire@skwire.net


v0.0.0.3 - 2009-09-29
    + Added optional showing/hiding of titlebar min/max/close buttons.

v0.0.0.2 - 2009-08-28
    * Hook now fires on two additional messages.
        HSHELL_REDRAW
        HSHELL_RUDEAPPACTIVATED

v0.0.0.1 - 2009-08-23
    + Initial build.

*/

#NoTrayIcon
#Persistent
#NoEnv
#SingleInstance, Force
SetWorkingDir, %A_ScriptDir%
DetectHiddenWindows, Off
OnExit, Cleanup
SysGet, TBarHeight, 4

Menu, Tray, NoStandard
Menu, Tray, Add, Exit, Cleanup

Gui +LastFound
hWnd := WinExist()

; Hook the shell.
; http://www.autohotkey.com/forum/viewtopic.php?p=123323#123323
DllCall( "RegisterShellHookWindow", UInt, hWnd )
MsgNum := DllCall( "RegisterWindowMessage", Str, "SHELLHOOK" )
OnMessage( MsgNum, "ShellMessage" )

; Create a blank cursor for use instead of a blank icon file.
; http://www.autohotkey.com/forum/viewtopic.php?p=220113#220113
VarSetCapacity( AndMask, 32*4, 0xFF ), VarSetCapacity( XorMask, 32*4, 0 )
hIcon := DllCall( "CreateCursor", Uint, 0, Int, 0, Int, 0, Int, 32, Int, 32, Uint, &AndMask, Uint, &XorMask )

; Initial loop to blank out existing windows.
WinGet, s, List
Loop, % s
{
    s := s%A_Index%
    ;SendMessage, 0x80, 0, hIcon, , % "ahk_id " . s
}

; MsgBox, 36, TBarIconBlanker, Would you like to enable the min/max/close buttons tweak as well?
; IfMsgBox, Yes
; {
;     MinMaxCloseOption := 1
;     SetTimer, WatchCursor, 100
; }
MinMaxCloseOption := 1
SetTimer, WatchCursor, 100

Return ; End of auto-execute section.


; ------------------------------------------------------------------------
; Subroutines ------------------------------------------------------------
; ------------------------------------------------------------------------

Cleanup:
{
    If ( MinMaxCloseOption = 1 ) ; Restore titlebar buttons on close.
    {
        WinGet, s, List
        Loop, % s
        {
            s := s%A_Index%
            WinSet, Style, +0x80000, % "ahk_id " . s ; Restore min/max/close buttons.
        }
    }
    ExitApp
}
Return


WatchCursor:
{
    MouseGetPos, , yPos, CurrID,
    If ( yPos >= 0 and yPos < ( TBarHeight + 3 ) )
    {
        WinSet, Style, +0x80000, % "ahk_id " . CurrID ; Restore min/max/close buttons.
        SendMessage, 0x80, 0, hIcon, , % "ahk_id " . CurrID ; Blank out titlebar and taskbar icons.
    }
    Else
    {
        WinSet, Style, -0x80000, % "ahk_id " . PrevID ; Get rid of min/max/close buttons.
        WinSet, Style, -0x80000, % "ahk_id " . CurrID ; Get rid of min/max/close buttons.
        SendMessage, 0x80, 0, hIcon, , % "ahk_id " . CurrID ; Blank out titlebar and taskbar icons.
    }
}
Return


; ------------------------------------------------------------------------
; Functions --------------------------------------------------------------
; ------------------------------------------------------------------------

; Shell hook to blank out windows that are subsequently created.
ShellMessage( wParam, lParam )
{
    Global hIcon, MinMaxCloseOption, PrevID
    If wParam in 1,6,32772
    {
        SendMessage, 0x80, 0, hIcon, , % "ahk_id " . lParam ; Blank out titlebar and taskbar icons.
        If ( MinMaxCloseOption = 1 )
        {
            WinSet, Style, -0x80000, % "ahk_id " . lParam ; Get rid of min/max/close buttons.
        }
    }
    PrevID := lParam
}



tmpusr

  • Instantiation stuck in meatspace with no backup
  • Member
  • Joined in 2005
  • **
  • Posts: 154
Re: [Compleet]: Auto replace icon in captionbar & taskbar
« Reply #29 on: September 29, 2009, 01:38 PM »
Thanks again.

Could you take a look at the changed taskbar button behavior: in many cases you need to click it twice until the window minimizes. And the right click menu is missing.

If you don't want to work on them, do you whether they are possible, like the overlaying of window borders with a solid color unless hovering there?

Without the buttons and icons the system looks much cleaner. I think this should be an option in Win 8 or Win 7 SP1, it's that good.

skwire

  • I eat Coding Snacks for breakfast...
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,297
    • Participated in NANY Challenge Seventeen Times
    • Coding Snacks
    • Superboy Coder
    • Cody Award
    • Volunteers/Staff
    • Gathering Badge
Re: [Compleet]: Auto replace icon in captionbar & taskbar
« Reply #30 on: September 29, 2009, 01:59 PM »
Could you take a look at the changed taskbar button behavior: in many cases you need to click it twice until the window minimizes. And the right click menu is missing.
Unfortunately, that's a side-effect of getting rid of the buttons.  The 0x80000 style is WM_SYSMENU.  So, basically, the code removes the window's system menu (the one you normally see when right-clicking or using the alt-space hotkey).

Honestly, for the amount of customisation you want to do, you may want to look into alternate Windows shell.  I, for instance, run a branch of the bb4Win shell called bbClean.  Using the bbLeanSkin plugin, you can specify which titlebar buttons to show (or none), whether or not icons show in the titlebar, etc.  Also, you can make the taskbar and tray icons greyscale, colour-muted, and on and on.  Take a look at the screenshots at http://www.boxshots.org for ideas.  You can see a screenshot of what my desktop typically looks like in an earlier post in this thread: http://www.donationcoder.com/forum/index.php?topic=19584.msg175110#msg175110

tmpusr

  • Instantiation stuck in meatspace with no backup
  • Member
  • Joined in 2005
  • **
  • Posts: 154
Re: [Compleet]: Auto replace icon in captionbar & taskbar
« Reply #31 on: September 29, 2009, 02:21 PM »
Wouldn't it be fixed simply by detecting that you're hovering over the taskbar and restoring the buttons - and thereby normal functionality - while you're there?

I'm pretty happy with the Explorer shell, but I'll take a look at BB.

I'm interested in the concept of stuff appearing only when you're near it. See nothing unless you're going to use it momentarily. Keep visual clutter to a minimum.

If you or someone could make the "hide window borders or overlay them with color while not near them", there's not much more I could think of improving - except for showing the icons in the taskbar at the same time as you're hovering over them. Which made me wonder, could you show the taskbar icons, but only while hovering over a window title?

Is it possible to show the window icon, too, when the buttons appear?

Is it possible to change the title bar font color and/or background color while you're hovering on it? I'd like to see it dim when I'm not near it, and get bright when hovering. The same goes for the taskbar text.

Is it possible to completely hide the titlebar until you move near it? So that the window actually is smaller and tiles as if it doesn't have the titlebar, but then the titlebar pops up when you're near it. The same for the statusbar too - auto-hide window titlebar and statusbar.

And heaps of thanks for your efforts. This has significantly changed the aesthetics of the OS for the better.
« Last Edit: September 29, 2009, 02:33 PM by tmpusr »

tmpusr

  • Instantiation stuck in meatspace with no backup
  • Member
  • Joined in 2005
  • **
  • Posts: 154
Re: [Compleet]: Auto replace icon in captionbar & taskbar
« Reply #32 on: September 29, 2009, 02:37 PM »
Found a great free app to remove all lines and rectangles from the taskbar, and to blank out the start button, leaving just an empty area of the size you can control, and to hide or replace the clock.
You can make the taskbar completely flat.
http://homepage1.nifty.com/kazubon/tclocklight/

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • Coding Snacks
    • Volunteers/Staff
    • Gathering Badge
    • Participated in NANY Challenge Once
    • Linux User

thwack

  • Participant
  • Joined in 2014
  • *
  • Posts: 1
Re: [Compleet]: Auto replace icon in captionbar & taskbar
« Reply #34 on: February 27, 2014, 07:09 PM »
sorry to bring an old topic but it's not working anymore, someone could fix it? there s still icons on certain apps, like firefox etc...

skwire

  • I eat Coding Snacks for breakfast...
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 5,297
    • Participated in NANY Challenge Seventeen Times
    • Coding Snacks
    • Superboy Coder
    • Cody Award
    • Volunteers/Staff
    • Gathering Badge
Re: [Compleet]: Auto replace icon in captionbar & taskbar
« Reply #35 on: February 27, 2014, 07:54 PM »
Hi, thwack, and welcome to the DonationCoder site.

sorry to bring an old topic but it's not working anymore, someone could fix it? there s still icons on certain apps, like firefox etc...

Unfortunately, this code was written four years ago for Windows XP and I'm not certain I'm too interested in updating it for Windows 7.  The code should be in the archive so you're welcome to do whatever you want with it.

Original address: https://www.donationcoder.com/forum/index.php?topic=19584.0