AutoIt taskbar autohide improvement script

Fixes problems with the Windows taskbar still not fixed by Microsoft.

1772 views

Edited: 2017-04-06 10:43

This AutoIt script is intended to improve how taskbar autohide works in Windows. The script works by disabling the taskbar while it is hidden, until either the Windows (WIN) key is pressed, or the user hovers the bottom of the screen for a few seconds.

A problem in Windows causes the taskbar to sometimes re-appear unintentionally, and sometimes it also becomes unresponsive when a window is maximized. This script should solve these problems by simply disabling the taskbar when hidden, and only make it re-appear when the user wants it to appear.

I hope that Microsoft will one day improve the taskbar, and fix these long lived issues. But until then, this script might be of help.

Requirements

This only works as intended if your taskbar is located at the bottom. The script was tested with a 1920x1080 screen resolution, but should also work with other resolutions.

You will need to download and install AutoIt to run the script. Save the script in a .au3 file, then right-click on it to run the script. Alternatively you can also compile the script into a stand-alone exe using AutoIt.

The script

#include <MsgBoxConstants.au3>
Sleep(1000)

Local $hWnd = WinWait("[CLASS:Shell_TrayWnd]", "", 10)
Local $aPos = WinGetPos($hWnd)
Global $hidden_position = $aPos[1]
Global $TaskBarFocus = 1
Global $hover_timer = 0

WinSetState($hWnd, "", @SW_DISABLE)

While 1
  TaskBarDisable()
  TaskBarEnable()
  Sleep(50);
WEnd


Func _IsPressed($hexKey)
  Local $aR, $bO
  $hexKey = '0x' & $hexKey
  $aR = DllCall("user32", "int", "GetAsyncKeyState", "int", $hexKey)
  If Not @error And BitAND($aR[0], 0x8000) = 0x8000 Then
    Return 1
  Else
    Return 0
  EndIf
EndFunc

Func TaskBarDisable()
  while $TaskBarFocus = 1
    Local $TaskBarPos = WinGetPos($hWnd)
    If $TaskBarPos[1] = $hidden_position Then
      WinSetState($hWnd, "", @SW_DISABLE)
      $TaskBarFocus = 0
    EndIf
  Wend
EndFunc

Func TaskBarEnable()
  Local $aPos = MouseGetPos()
  If _IsPressed("5B") Or _IsPressed("5C") Then
    WinSetState($hWnd, "", @SW_ENABLE)
    $TaskBarFocus = 1
    Sleep(1000)
  ElseIf $aPos[1] > $hidden_position-40 Then
    sleep(1000)
    $hover_timer = $hover_timer+1
    If $hover_timer > 2 Then
      WinSetState($hWnd, "", @SW_ENABLE)
      $TaskBarFocus = 1
      $hover_timer = 0
      sleep(500)
    EndIf
  Else
    $hover_timer = 0
  EndIf

EndFunc

Tell us what you think:

  1. How to declare and work with variables in AutoIt, as well as some background information.
  2. Everything you need to know about working with minimized windows.
  3. How to set the request headers when performing HTTP requests.
  4. This Tutorial will focus on post requests in AutoIt, using the Winhttprequest.5.1 object.
  5. How to use while, for, and do until loops, and how to loop through arrays and object in AutoIt.

More in: AutoIt Tutorials