Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Hide the Sidewise icon from the Windows taskbar and take it out of the alt-tab list.
;#NoTrayIcon ; uncomment this to also hide this script's systray icon
init()
return
init() {
; Configure event hook for window-created message reception
Gui +LastFound
hWnd := WinExist()
DllCall( "RegisterShellHookWindow", UInt,hWnd )
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
OnMessage( MsgNum, "ShellMessage" )
HideSidewise()
return
}
HideSidewise() {
title := "Sidewise ahk_class Chrome_WidgetWin_1"
if (!WinExist(title)) {
return
}
WinSet, ExStyle, +0x80, %title% ; hide from alt-tab order
RemoveWindowFromTaskbar(title)
return
}
RemoveWindowFromTaskbar(WinTitle) {
/*
Example: Temporarily remove the active window from the taskbar by using COM.
Methods in ITaskbarList's VTable:
IUnknown:
0 QueryInterface -- use ComObjQuery instead
1 AddRef -- use ObjAddRef instead
2 Release -- use ObjRelease instead
ITaskbarList:
3 HrInit
4 AddTab
5 DeleteTab
6 ActivateTab
7 SetActiveAlt
*/
IID_ITaskbarList := "{56FDF342-FD6D-11d0-958A-006097C9A090}"
CLSID_TaskbarList := "{56FDF344-FD6D-11d0-958A-006097C9A090}"
; Create the TaskbarList object and store its address in tbl.
tbl := ComObjCreate(CLSID_TaskbarList, IID_ITaskbarList)
activeHwnd := WinExist(WinTitle)
DllCall(vtable(tbl,3), "ptr", tbl) ; tbl.HrInit()
DllCall(vtable(tbl,5), "ptr", tbl, "ptr", activeHwnd) ; tbl.DeleteTab(activeHwnd)
Sleep 3000
DllCall(vtable(tbl,4), "ptr", tbl, "ptr", activeHwnd) ; tbl.AddTab(activeHwnd)
; Non-dispatch objects must always be manually freed.
ObjRelease(tbl)
return
}
vtable(ptr, n) {
; NumGet(ptr+0) returns the address of the object's virtual function
; table (vtable for short). The remainder of the expression retrieves
; the address of the nth function's address from the vtable.
return NumGet(NumGet(ptr+0), n*A_PtrSize)
}
ShellMessage( wParam,lParam )
{
WinGetClass, Class, ahk_id %lParam%
WinGetTitle, Title, ahk_id %lParam%
if ((wParam == 6 || wParam == 1 || wParam == 2) && (Title == "Sidewise" && Class == "Chrome_WidgetWin_1"))
{
HideSidewise()
return
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment