Taskbar "Automatically hide the taskbar in desktop mode"

Post your working scripts, libraries and tools
Posts: 21
Joined: 27 Oct 2015, 18:45

Taskbar "Automatically hide the taskbar in desktop mode"

22 Oct 2018, 11:26

Hello fellow AHKers,

Apologies in advance if this is redundant, but after years of wanting this; I've finally been able to accomplish it. Turns out it was ridiculously simple, at least in Windows 10.

I work via Remote Desktop (RDP/VNC/etc) connections all the time, via a window instead of full screen - e.g. mRemoteNG. I like to keep the Taskbar set to "Automatically hide the taskbar in desktop mode" when logged in locally. This is a pain in the neck though when I connect to a remote computer where that taskbar is also set to "Automatically hide...". Trying to bring up the correct taskbar can be an exercise in pixel perfect mouse orchestrations; or requires clicking into the remote desktop window, or outside of the window to set the keyboard focus as desired.

I put together the script below that I compiled and compressed into a little executable. The script will hide the taskbar when hide is passed to it, show the taskbar when show is passed to it; and toggle the taskbar state when nothing or anything else is passed. I created two tasks in Task Scheduler that are triggered by an "On connection to user session" event. The Show Taskbar task's trigger event is set for "Connection from remote computer" while the Hide Taskbar task is set for "Connection from local computer". Now when I connect remotely the Taskbar is set to always be visible, and when I login locally it is automatically hidden.

Any feedback for improvements/best practices/crass stupidity on my part is always appreciated.

Code: Select all

ABS_AUTOHIDE      := 1
ABM_GETSTATE      := 4
ABM_SETSTATE      := 10
Pointer32bit      := 4
Pointer64bit      := 8
PtrOffSet         := A_PtrSize = Pointer32bit ? 32:40
RequestedCapacity := A_PtrSize = Pointer32bit ? 36:48

Parameter = % A_Args[1]

VarSetCapacity(APPBARDATA, RequestedCapacity)
SHBarState := DllCall("Shell32\SHAppBarMessage", "UInt", ABM_GETSTATE, "Ptr", &APPBARDATA, "Int")

if Parameter = hide
	if Parameter = show

DllCall("Shell32\SHAppBarMessage", "UInt", ABM_SETSTATE, "Ptr", &APPBARDATA)

Cheers my dears. :superhappy:

Return to “Scripts and Functions”

Who is online

Users browsing this forum: AHKStudent, Bing [Bot], boiler, comvox and 64 guests