@sylremo thank you for this
I modified it according to my needs
; https://www.autoitscript.com/forum/topic/154281-taskbar-problems/?do=findComment&comment=1517375
; FileVersion:3, Testet on Win10 22H2, with AutoIt Version:3.3.16.1
;----------------------------------------------------------------------------------------
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7
;~ #AutoIt3Wrapper_UseX64=y
ConsoleWrite("TaskbarState=" & TaskbarState() & @CRLF)
; #FUNCTION# --------------------------------------------------------------------------------------------------------------------
; Name...........: TaskbarState
; Description....: Sets or gets the state of the taskbar.
; Syntax.........: TaskbarState([$iState])
; Parameters.....: $iState - [optional] The new state of the taskbar. Can be one of the following values:
; 1 - Auto-hide the taskbar.
; 2 - Always on top.
; 3 - Toggle the current state of the taskbar.
; Return values..: The current state of the taskbar. Can be one of the following values:
; Success: 1 = Auto-hide, 2 = Always on top.
; Failure: 0 and sets the @error flag to non-zero.
; Author ........: sylremo, mod:ioa747
; Notes .........: if no value in $iState then return the state of the taskbar
; Link ..........: https://www.autoitscript.com/forum/topic/154281-taskbar-problems/#comment-1538596
;--------------------------------------------------------------------------------------------------------------------------------
Func TaskbarState($iState = "")
Local Const $ABM_GETSTATE = 0x00000004
Local Const $ABM_SETSTATE = 0x0000000A
Local Const $ABS_AUTOHIDE = 0x00000001
Local Const $ABS_ALWAYSONTOP = 0x00000002
Local $tAPPBARDATA = DllStructCreate('dword;hwnd;dword;dword;int[4];dword')
DllStructSetData($tAPPBARDATA, 1, DllStructGetSize($tAPPBARDATA))
Local $iCurrentState = DllCall('shell32.dll', 'int', 'SHAppBarMessage', 'dword', $ABM_GETSTATE, 'ptr', DllStructGetPtr($tAPPBARDATA))
If Not @error And IsArray($iCurrentState) Then
Local $iNewState = $iCurrentState[0] ? $ABS_ALWAYSONTOP : $ABS_AUTOHIDE
DllStructSetData($tAPPBARDATA, 6, $iNewState)
$iCurrentState = $iCurrentState[0] = 1 ? 1 : 2
If $iState = 1 Or $iState = 2 Then
If $iCurrentState <> $iState Then
DllCall('shell32.dll', 'int', 'SHAppBarMessage', 'dword', $ABM_SETSTATE, 'ptr', DllStructGetPtr($tAPPBARDATA))
$iCurrentState = $iNewState
EndIf
ElseIf $iState = 3 Then
DllCall('shell32.dll', 'int', 'SHAppBarMessage', 'dword', $ABM_SETSTATE, 'ptr', DllStructGetPtr($tAPPBARDATA))
$iCurrentState = $iNewState
EndIf
Return $iCurrentState
EndIf
Return SetError(1, 0, 0)
EndFunc ;==>TaskbarState
Thanks to @argumentum it now also works on x64
Thanks to @Nine I removed the unnecessary call DllStructSetData()