The reason of bug connected with tray (notification area), manually click on tray arrow usually could help to hide taskbar for once.
Script below reimplements auto-hide functionality, works with taskbar in any position (bottom, left, top, right):
Code: Select all
; _______Settings________
hideDelay := 300 ; ms
;========================
; #NoTrayIcon
#SingleInstance force
#Persistent
SetBatchLines -1
SetMouseDelay -1
SetWinDelay -1
CoordMode Mouse, Screen
OnExit Exit
global taskBarVis, xTaskBar, yTaskBar, wTaskBar, hTaskBar, taskBarOnTop, hideDelay
WinGetPos xTaskBar, yTaskBar, wTaskBar, hTaskBar, ahk_class Shell_TrayWnd ahk_exe explorer.exe
taskBarOnTop := yTaskBar < 0
DetectHiddenWindows On
hwndTaskBar := WinExist("ahk_class Shell_TrayWnd ahk_exe explorer.exe")
taskBarVis := DllCall("IsWindowVisible", Ptr, hwndTaskBar) ; originally invisible only on top
; MsgBox % xTaskBar " | " yTaskBar " | " wTaskBar " | " hTaskBar " | " taskBarVis := DllCall("IsWindowVisible", Ptr, hwndTaskBar)
; maybe hook is not cool for perfomance (possible freeze) and simple timer would be better
hHookMouse := DllCall("SetWindowsHookEx" . (A_IsUnicode ? "W" : "A")
, Int, WH_MOUSE_LL := 14
, Ptr, RegisterCallback("LowLevelMouseProc", "Fast")
, Ptr, DllCall("GetModuleHandle", UInt, 0, Ptr)
, UInt, 0, Ptr)
Return
; F1::showTaskBar()
; F2::hideTaskBar()
; Esc::ExitApp
Exit:
DllCall("UnhookWindowsHookEx", Ptr, hHookMouse)
showTaskBar()
ExitApp
LowLevelMouseProc(nCode, wParam, lParam) {
static WM_MOUSEMOVE := 0x200 ;, i := 0, j := 0
if (nCode < 0 || wParam != WM_MOUSEMOVE) ;
Return DllCall("CallNextHookEx", Ptr, 0, Int, nCode, UInt, wParam, UInt, lParam)
x := NumGet(lParam+0, "Int"), y := NumGet(lParam+0, 4, "Int")
; ToolTip % x ":" y "`n" yTaskBar " " yTaskBar+hTaskBar,,, 1
If ((!taskBarVis or taskBarOnTop) and (x >= xTaskBar and x <= xTaskBar+wTaskBar && y >= yTaskBar-1 and y <= yTaskBar+hTaskBar)) {
taskBarVis := 1
; ToolTip % ++i, 100, 100, 2
SetTimer showTaskBar, -1
}
Else if (taskBarVis and !(x > xTaskBar-wTaskBar and x < xTaskBar+2*wTaskBar && y > yTaskBar-hTaskBar and y < yTaskBar+ 2*hTaskBar)) {
taskBarVis := 0
; ToolTip % ++j, 200, 100, 3
SetTimer hideTaskBar, % -hideDelay
}
Return
}
hideTaskBar() {
; static hMenuStart := WinExist("ahk_class DV2ControlHost")
MouseGetPos x, y ;, hWin, ControlClNN, 1
If !(x > xTaskBar-30 and x < xTaskBar+wTaskBar+30 && y > yTaskBar-30 and y < yTaskBar+hTaskBar+30) {
WinHide ahk_class Shell_TrayWnd ahk_exe explorer.exe
WinHide Start ahk_class Button ahk_exe explorer.exe
} else {
taskBarVis := 1
}
}
showTaskBar() {
WinShow ahk_class Shell_TrayWnd ahk_exe explorer.exe
; WinActivate ahk_class Shell_TrayWnd ahk_exe explorer.exe ; Show without activation for fullscreen apps
WinShow Start ahk_class Button ahk_exe explorer.exe
}
Next feature I try to implement is not show taskbar immediately when cursor reache the desktop edge, only if cursor move some pixels along the edge. It must to prevent accidental taskbar appearence.
Next code is prototype, work only for bottom taskbar position:
Spoiler
Another possible feature is show taskbar even for fullscreen programs. In combination with prevent accidental taskbar appearence it must work well, but I'm too lazy.