Fast_And_Pleasant_Taskbar_Toggle() - toggle win10 taskbar the way you toggle tabbars in say firefox

Post your working scripts, libraries and tools for AHK v1.1 and older
20170201225639
Posts: 144
Joined: 01 Feb 2017, 22:57

Fast_And_Pleasant_Taskbar_Toggle() - toggle win10 taskbar the way you toggle tabbars in say firefox

16 Oct 2018, 09:21

(a link to a video can be found at the bottom)

This simple function allows you to toggle win10 taskbar in a way that I find extremely pleasant and seamless.

The typical way to do this is by defining a hotkey that alternately calls WinHide and WInShow on "ahk_class Shell_TrayWnd".

There are 3 problems with this approach:
* when taskbar is WInHidden, the area of screen it formerly occupies is left blank. That kinda defeats the whole purpose of hiding the taskbar doesn't it? You want that screen real estate!
* if you have a background app switched into fullscreen mode (and your foreground app isn't also in fullscreen), you can see a little bit of it in that area, which can bother you a lot.
* the toggling simply doesn't work if your foreground app is in fullscreen mode (which 90% of my apps are) --- callling WinShow on taskbar doesn't display the taskbar, even if you use WinSet Top/AlwaysOnTop)

The natural alternative is to make the hotkey toggle, not the visibility of taskbar, but its autohide status.

But if you've ever tried that, you know that each time you toggle it on/off, all of your maximized windows are resized to adapt to the new maximized window size. It's anything but "smooth". (Although, if you only want to very occasionally toggles autohide status, you can perhaps live with that)

A third idea is to set taskbar to autohide always, but define a hotkey to alternately move to/away from the (say) bottom edge of the screen, to show/hide the taskbar.

But this is undesirable because:
* mouse movement is distracting
* there's a distracting delay both when you toggle on, and especially when you toggle off the taskbar. The taskbar takes 1 second to disappear


After much experimentation I finally found a way to toggle the taskbar that I find completely satisfactory, at least for me.

For it to work, you must set taskbar to autohide

Then make some key (F1 for purpose of illustration) call this function.

Code: Select all

F1:
Fast_And_Pleasant_Taskbar_Toggle(){
	if (WinActive("ahk_class Shell_TrayWnd"))
	{
		WinHide, ahk_class Shell_TrayWnd
		Send !{Esc}
	}
	else
	{
		WinShow ahk_class Shell_TrayWnd
		WinActivate ahk_class Shell_TrayWnd
	}
}
The result looks like this - note that (i) my taskbar is at the top of the screen (it works if it's at the bottom of course) and (ii) the foreground app is fullscreen mode

https://gfycat.com/ifr/MelodicShrillJavalina

Image
User avatar
Thoughtfu1Tux
Posts: 125
Joined: 31 May 2018, 23:26

Re: Fast_And_Pleasant_Taskbar_Toggle() - toggle win10 taskbar the way you toggle tabbars in say firefox

17 Oct 2018, 02:14

I use RadialMenu at work to toggle between windows and programs really quickly and very rarely use the taskbar. I haven’t thought about hiding it, but after seeing your example I think it would be a really nice to hide it away because it is mind of distracting. I’m going to try out your script tomorrow when I get to work, thanks for sharing it.

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 57 guests