0

I am trying to manipulate the auto-hide taskbar feature in Windows 11 using C language. I want to enable auto-hide when using the laptop alone, and disable it when connecting a monitor via C-type. However, when I wrote and executed the code as shown above, it didn't work.

It is possible to completely hide or show the taskbar using code, but it seems that there is no direct way to enable or disable the auto-hide feature through code.

Thank you for your response.

#include <Windows.h>
#include <tchar.h>
#include <shellapi.h>
#include <stdio.h>


int main() {
    DISPLAY_DEVICE displayDevice = { 0 };
    displayDevice.cb = sizeof(DISPLAY_DEVICE);
    DWORD deviceIndex = 0;


    HWND taskbar = FindWindow(_T("Shell_TrayWnd"), NULL);
    APPBARDATA abd = { 0 };
    memset(&abd, 0, sizeof(APPBARDATA));
    abd.cbSize = sizeof(APPBARDATA);
    abd.hWnd = taskbar;
    //SHAppBarMessage(ABM_SETAUTOHIDEBAR, 0, 0, &abd);

    while (EnumDisplayDevices(NULL, deviceIndex, &displayDevice, 0)) {
        if (displayDevice.StateFlags == DISPLAY_DEVICE_ATTACHED_TO_DESKTOP) {
            SHAppBarMessage(ABM_SETSTATE, ABS_AUTOHIDE, &abd);
        }
        deviceIndex++;
    }
    return 0;
}
tojaman
  • 1
  • 1

0 Answers0