A command or message or DLL call to set automatic hiding of Windows taskbar?

别等时光非礼了梦想. 提交于 2020-05-16 05:37:30

问题


I need to set or toggle auto-hiding of Windows 10 taskbar programmatically. An action bound to a hotkey for productivity and convenience. Is there a command-line command or a DLL call which allows to achieve equivalent of flipping the following switch:

Currently I am achieving this by opening the above Settings window and sending keystrokes for search, followed by Downs and Space and Alt+F4 but it is slow and unreliable.

This question is not language-specific since DLL calls look pretty much the same everywhere, although my final implementation will be in AutoHotKey.

Expected result: After running the command, the Windows Explorer will change its behavior as if the setting Automatically hide the taskbar in desktop mode was enabled (or disabled or toggled).


回答1:


It is ABM_SETSTATE message.

After finding the proper Windows message I have also found the implementation in AutoHotKey:

ABM_SETSTATE    := 10
ABS_NORMAL      := 0x0
ABS_AUTOHIDE    := 0x1
ABS_ALWAYSONTOP := 0x2
VarSetCapacity(APPBARDATA, 36, 0)
Address := NumPut(36, APPBARDATA)
Address := NumPut(WinExist("ahk_class Shell_TrayWnd"), Address + 0)
NumPut(ABS_NORMAL, Address + 24)
DllCall("Shell32.dll\SHAppBarMessage", UInt, ABM_SETSTATE, UInt, &APPBARDATA)

Change the parameter in the second line from the bottom from ABS_NORMAL to ABS_AUTOHIDE to achieve the expected other state.



来源:https://stackoverflow.com/questions/53367237/a-command-or-message-or-dll-call-to-set-automatic-hiding-of-windows-taskbar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!