0

I need to hide an app icon when it starts minimized from the taskbar, for example when you start a program minimized, how can you hide the app from the taskbar? Im not talking about tray icons on the right side with the ^, I'm talking about TASKBAR in the middle.

1 Answers1

0

HideTaskbarBtn.exe Hides or shows a window on the taskbar.

This uses the inbuilt compilers in Windows 10 - there are three VB.NET compilers and three C# compilers

Windows that are normal, a titlebar with a system menu, appear on the taskbar. Windows that want to appear on the taskbar but don't meet the requirements can set an extended window's style of an AppWindow. To remove a window from the taskbar requires the window to be hidden, the AppWindow extended style forcing it onto the taskbar to be removed and the extended style of a tool palette window applied. Then show the window. The new window won't have a titlebar icon.

This does not work with UWP apps, only Win32 applications and consoles.

If you run this on a minimised window there is no way of activating the window. See Assigns a hotkey to a window if you need to. If you run this on a non-minimised program then minimise the program a Windows 3.11 minimised desktop icon appears.

Just copy each text file into the same folder and double click the batch file to make the program.


@Echo Off
Echo HideTaskbarBtn.bat
Echo This file compiles HideTaskbarBtn.vb to HideTaskbarBtn.exe
Echo HideTaskbarBtn.exe hides or shows a window'a button on the taskbar
Echo To use 
Echo     HideTaskbarBtn Hide <Window Title>
Echo     HideTaskbarBtn Show <Window Title>
Echo E.G.
Echo     HideTaskbarBtn Hide Untitled - Notepad
Echo     HideTaskbarBtn Show Untitled - Notepad
Echo -----------------------------------------------------
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\vbc.exe" /target:winexe /out:"%~dp0\HideTaskbarBtn.exe" "%~dp0\HideTaskbarBtn.vb" 
pause

'HideTaskbarBtn.vb
Imports System
Imports System.IO
Imports System.Runtime.InteropServices
Imports Microsoft.Win32

Public Module TopMost Public Declare UNICODE Function FindWindowW Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As IntPtr, ByVal hWndInsertAfter As Integer, ByVal x As Integer, ByVal y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer) As Integer Public Declare Function SetWindowLongPtrW Lib "user32" (ByVal hwnd As IntPtr, ByVal Index As Integer, ByVal NewValue As Integer) As Integer Public Declare Function GetWindowLongPtrW Lib "user32" (ByVal hwnd As IntPtr, ByVal Index As Integer) As Integer Public Declare Function GetParent Lib "user32.dll" (ByVal hwnd As Intptr) As IntPtr

Public Const WS_EX_APPWINDOW = &amp;h40000
Public Const WS_EX_TOOLWINDOW = &amp;h80
Public Const WS_MINIMIZEBOX = &amp;h20000
Public Const GWL_EXSTYLE = -20
Public Const GWL_STYLE = -16

Public Const HWND_TOPMOST = -1
Public Const HWND_NOTOPMOST = -2
Public Const SWP_NOMOVE = &amp;H2
Public Const SWP_NOSIZE = &amp;H1
Public Const SWP_SHOWWINDOW = &amp;H40
Public Const SWP_HIDEWINDOW = &amp;H80
Public Const SWP_NOOWNERZORDER = &amp;H200      '  Don't do owner Z ordering
Public Const SWP_NOREDRAW = &amp;H8
Public Const SWP_NOREPOSITION = &amp;H200
Public Const SWP_NOZORDER = &amp;H4

Sub Main()
    On Error Resume Next
    Dim hWindows as IntPtr
    Dim CmdLine as String
    Dim Ret as Integer
    Dim ExStyle as Integer
    Dim Style as Integer
    CmdLine = Mid(Command(),6)
    hwindows = FindWindowW(vbNullString, CmdLine)
    If hwindows = 0 then
        Msgbox(Cmdline &amp; &quot; cannot be found.&quot;)
    Else
        If LCase(Left(Command(), 4)) = LCase(&quot;Hide&quot;) then
            Ret = GetWindowLongPtrW(hWindows, GWL_EXSTYLE)
            ExStyle = Ret
            'Test AppWindow is set and if so remove it
            If (ExStyle And WS_EX_APPWINDOW) = WS_EX_APPWINDOW then ExStyle = ExStyle - WS_EX_APPWINDOW
            If (ExStyle And WS_EX_TOOLWINDOW) &lt;&gt; WS_EX_TOOLWINDOW then ExStyle = ExStyle + WS_EX_TOOLWINDOW
            Ret = SetWindowPos(hwindows, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE + SWP_NOZORDER + SWP_HIDEWINDOW)
            Ret = GetWindowLongPtrW(hWindows, GWL_EXSTYLE)
            'SetWindowLongPtr does not clear GetLastError if sucessful.
            err.clear
            Ret = SetWindowLongPtrW(hWindows, GWL_EXSTYLE, ExStyle)
            If (Ret = 0 And err.LastDLLError &lt;&gt; 0) Then MsgBox(&quot;SetWindowLongPtrW is &quot; &amp; Err.LastDllError)
            err.clear

' Ret = SetWindowLongPtrW(hWindows, GWL_STYLE, Style) ' If (Ret = 0 And err.LastDLLError <> 0) Then MsgBox("SetWindowLongPtrW is " & Err.LastDllError) Ret = SetWindowPos(hwindows, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE + SWP_NOZORDER + SWP_SHOWWINDOW) If Ret = 0 Then MsgBox("Set Pos Error is " & Err.LastDllError) ElseIf LCase(Left(Command(), 4)) = LCase("Show") then Ret = GetWindowLongPtrW(hWindows, GWL_EXSTYLE) 'Test AppWindow is set and if so remove it ExStyle = Ret If (ExStyle And WS_EX_APPWINDOW) <> WS_EX_APPWINDOW then ExStyle = ExStyle + WS_EX_APPWINDOW If (ExStyle And WS_EX_TOOLWINDOW) = WS_EX_TOOLWINDOW then ExStyle = ExStyle - WS_EX_TOOLWINDOW Ret = SetWindowPos(hwindows, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE + SWP_NOZORDER + SWP_HIDEWINDOW) If Ret = 0 Then MsgBox("Set Pos Error is " & Err.LastDllError) err.clear Ret = SetWindowLongPtrW(hWindows, GWL_EXSTYLE, ExStyle) If (Ret = 0 And err.LastDLLError <> 0) Then MsgBox("SetWindowLongPtrW is " & Err.LastDllError) Ret = SetWindowPos(hwindows, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE + SWP_NOZORDER + SWP_SHOWWINDOW) If Ret = 0 Then MsgBox("Set Pos Error is " & Err.LastDllError) Else Msgbox("Command line not recognised") End If End If End Sub End Module


From https://winsourcecode.blogspot.com/2021/04/this-uses-inbuilt-compilers-in-windows.html


To use

    HideTaskbarBtn Hide Untitled - Notepad