[Func] _MoveTaskBar
Posté : ven. 21 août 2015 17:51
Bonjour. Voici une petite fonction permettant de modifier quelques propriétés de la barre des tâche :
Cette fonction n’a aucun besoin d'élévation de droits (UAC).
Je joint un code de démonstration pour celui qui voudrait tester la fonction en condition (Je referais peut être l'interface un jour avec des boutons radio, car là elle est vraiment trop moche.
).
- - Position de la barre sur l'écran (haut, bas, gauche, droite)
- Masquage automatique de la barre
- Verrouillage de la barre
Cette fonction n’a aucun besoin d'élévation de droits (UAC).
Code : Tout sélectionner
; #FUNCTION# ====================================================================================================================
; Name ..........: _MoveTaskBar
; Description ...: Moves the Windows Taskbar to a New Location on the Screen.
; Syntax ........: _MoveTaskBar([$ScreenPos [, $iAutoHide = Default [, $iLock = Default]]])
; Parameters ....: $ScreenPosX = Left, Right, Top, Bottom or -1 if you want to keep actual position (default value Bottom)
; $iAutoHide = 0, 1 or -1 if you want to keep actual value (default value -1)
; $iLock = 0, 1 or -1 if you want to keep actual value (default value -1)
; Return values .: Success - True
; Failure - False and set @error = 1
; Author ........: Tlem
; Remarks .......: Tested on windows XP, 7, 8.1 and 10
; Example .......:
; Note ..........:
; ===============================================================================================================================
Func _MoveTaskBar($ScreenPos = "Bottom", $iAutoHide = -1, $iLock = -1)
Local $StuckRects = (@OSVersion = "WIN_10") ? "StuckRects3" : "StuckRects2"
Local $sStuckRectsHKey = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\" & $StuckRects
Local $sLockHKey = "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\"
; Set the $iLock and $iAutoHide values according to the input values (use ternary operator)
$iAutoHide = ($iAutoHide = -1) ? StringMid(RegRead($sStuckRectsHKey, "Settings"), 19, 2) : (($iAutoHide = 0) ? "02" : "03")
$iLock = ($iLock = -1) ? RegRead($sLockHKey, "TaskbarSizeMove") : (($iLock = 1) ? 0x00 : 0x01)
; Set the value for desired position. If -1 get actual value else return an error
Select
Case $ScreenPos = "Bottom"
$ScreenPos = "0x28000000ffffffff02000000030000003e0000002e000000000000008204000080070000b0040000"
Case $ScreenPos = "Left"
$ScreenPos = "0x28000000ffffffff02000000000000003e0000002e00000000000000000000003e000000b0040000"
Case $ScreenPos = "Right"
$ScreenPos = "0x28000000ffffffff02000000020000003e0000002e000000420700000000000080070000b0040000"
Case $ScreenPos = "Top"
$ScreenPos = "0x28000000ffffffff02000000010000003e0000002e0000000000000000000000800700002e000000"
Case $ScreenPos = -1
$ScreenPos = RegRead($sStuckRectsHKey, "Settings")
Case Else
Return SetError(1, 0, 0)
EndSelect
$ScreenPos = StringMid($ScreenPos, 1, 18) & $iAutoHide & StringMid($ScreenPos, 21) ; Merge position and autohide values
RegWrite($sStuckRectsHKey, "Settings", "REG_BINARY", $ScreenPos) ; New position with Autohide key
RegWrite($sLockHKey, "TaskbarSizeMove", "REG_DWORD", $iLock) ; New lock/unlock key
; Restart Explorer for activate new parameters
$Kernel32 = DllOpen("kernel32.dll")
$hproc = DllCall($Kernel32, 'int', 'OpenProcess', 'int', 0x1F0FFF, 'int', True, 'int', ProcessExists('explorer.exe'))
DllCall($Kernel32, "int", "TerminateProcess", "int", $hproc[0], "dword", 0)
DllClose($Kernel32)
Return 1
EndFunc ;==>MoveTaskBar
