This should do it.
Code: Select all
;ABM_GETSTATE message (Windows)
;https://msdn.microsoft.com/en-us/library/windows/desktop/bb787947(v=vs.85).aspx
;Note As of Windows 7, ABS_ALWAYSONTOP is no longer returned because the taskbar is always in that state. Older code should be updated to ignore the absence of this value in not assume that return value to mean that the taskbar is not in the always-on-top state.
q:: ;taskbar - toggle auto-hide/always-on-top
vToggle := !vToggle * 0x3
;ABM_SETSTATE := 0xA
VarSetCapacity(APPBARDATA, A_PtrSize=8?48:36, 0)
NumPut(vToggle, &APPBARDATA, A_PtrSize=8?40:32, "UInt")
DllCall("shell32\SHAppBarMessage", UInt,0xA, Ptr,&APPBARDATA, UPtr)
return
w:: ;taskbar - get state - auto-hide/always-on-top
VarSetCapacity(APPBARDATA, A_PtrSize=8?48:36, 0)
;ABM_GETSTATE := 0x4
vState := DllCall("shell32\SHAppBarMessage", UInt,0x4, Ptr,&APPBARDATA, UPtr)
;from shellapi.h
;ABS_ALWAYSONTOP := 0x2 ;ABS_AUTOHIDE := 0x1
MsgBox, % "auto-hide: " (vState & 0x1 ? "on" : "off")
MsgBox, % "always-on-top: " (vState & 0x2 ? "on" : "off")
return
It appears you can't change the on-top status of the taskbar, at least by this method.
Code: Select all
e:: ;attempt to toggle/turn off taskbar always-on-top (didn't work) (tested on Windows 7)
WinGet, vWinExStyle, ExStyle, ahk_class Shell_TrayWnd
MsgBox, % Format("0x{:08X}", vWinExStyle)
;WinSet, ExStyle, ^0x8, ahk_class Shell_TrayWnd
WinSet, ExStyle, 0x80, ahk_class Shell_TrayWnd
return
To lock the taskbar:
taskbar - Lock or disable resizing of task bar autohotkey - Stack Overflow
https://stackoverflow.com/questions/407 ... autohotkey
[EDIT:] Here's some code to get/set the locked state:
Code: Select all
q:: ;taskbar - toggle lock/unlock
PostMessage, 0x111, 424, 0,, ahk_class Shell_TrayWnd
return
w:: ;taskbar - get locked state
RegRead, vIsMovable, HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced, TaskbarSizeMove
MsgBox, % "taskbar is locked: " (vIsMovable ? "n" : "y")
return