Jump to content

[Solved] Windows 7 Taskbar Auto-Hide


IanN1990
 Share

Recommended Posts

Heya,

I have 2 questions :D

If you right click the windows 7 taskbar, go to options, and tick "Auto-Hide the Taskbar". It increases the size of the screen for apps "cuz the taskbar is kinda gone" unless u hover ur mouse to the location of the bar and it slowly appears. Also when the bar is inactive it shows this horrible line reminding you of the location of it :oops:

#NoTrayIcon
#Include <WinAPI.au3>
_ShowTaskBar(1)
Func _ShowTaskBar($fShow)
Local $hTaskBar
If @OSVersion = "WIN_VISTA" or @OSVersion = "WIN_2008" or @OSVersion = "WIN_7" Then _ShowStartButton($fShow)
$hTaskBar = _WinAPI_FindWindow("Shell_TrayWnd", "")
If $fShow=0 Then
_WinAPI_ShowWindow($hTaskBar, @SW_SHOW)
Else
_WinAPI_ShowWindow($hTaskBar, @SW_HIDE)
EndIf
EndFunc ;==>_ShowTaskBar
Func _ShowStartButton($fShow )
Local $hTaskBar, $hStartButton
If @OSVersion = "WIN_VISTA" or @OSVersion = "WIN_2008" or @OSVersion = "WIN_7" Then
$hStartButton = _WinAPI_FindWindow("Button", "Start")
Else
$hTaskBar = _WinAPI_FindWindow("Shell_TrayWnd", "")
$hStartButton = ControlGetHandle($hTaskBar, "", "Button1")
EndIf
If $fShow=0 Then
_WinAPI_ShowWindow($hStartButton, @SW_SHOW)
Else
_WinAPI_ShowWindow($hStartButton, @SW_HIDE)
EndIf
EndFunc ;==>

Now with that code, it can be used to Show or Hide the taskbar, but i have noticed some system tasks "like closing task-manager" will show the bar again, meaning this code needs to be re-run but i cant think of any way of checking weather the bar is hidden or not. I tryed using WinGetPos, WinActive, WinGetState but couldn't find any ideas?? :rip:

My second question is to increase the speed a bit, i found when the taskbar is "active" it doesn't do the slow fade in and fade out animation "with my code of just show and hide it would be alot faster" is there any way for some code to set the bar to constantly active without affecting anything else ? "Ie if i used WInActivate on a loop, it would do this but i would also lose focus every time the code is run"

Thanks :)

Edited by IanN1990
Link to comment
Share on other sites

Found on the Forum sometime ago (can't find the link) >>

ConsoleWrite(_TaskbarHidden() & @CRLF)
ConsoleWrite(_TaskbarOnTop() & @CRLF)

Func _TaskbarHidden() ; 0 = Shown Or 1 = Hidden
    Local Const $ABM_GETSTATE = 0x00000004
    Local $aReturn
    $aReturn = DllCall('shell32.dll', 'uint', 'SHAppBarMessage', 'dword', $ABM_GETSTATE, 'ptr*', 0)
    If @error Then
        Return SetError(1, 0, 0)
    EndIf
    If BitAND($aReturn[0], 0x01) Then
        Return 1
    EndIf
EndFunc   ;==>_TaskbarHidden

Func _TaskbarOnTop() ; 0 = Not OnTop Or 1 = OnTop
    Local Const $ABM_GETSTATE = 0x00000004
    Local $aReturn
    $aReturn = DllCall('shell32.dll', 'uint', 'SHAppBarMessage', 'dword',  $ABM_GETSTATE, 'ptr*', 0)
    If @error Then
        Return SetError(1, 0, 0)
    EndIf
    If BitAND($aReturn[0], 0x02) Then
        Return 1
    EndIf
EndFunc   ;==>_TaskbarOnTop

Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Another alternative was getting the position with ControlGetPos or WinGetPos but that didn't work so next step is to search MSDN.

Edit: About SHAppBarMessage

Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

Also _TaskbarHidden works on Windows 7 x64 with the latest beta of AutoIt. But look at this >>

Edited by guinness

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

I ran that code, and the code you posted earlier. They do both indeed detect weather the taskbar is set to auto-hide or not but in this case thats not what i am after "this is my fault for not explaining clearly".

Bascily, I have some code that watches where the mouse goes. When it goes to the top of the right-screen, it runs this exe.

#NoTrayIcon
#include <Misc.au3>
#Include <WinAPI.au3>
_ShowTaskBar(0)
Func _ShowTaskBar($fShow)
Local $hTaskBar
If @OSVersion = "WIN_VISTA" or @OSVersion = "WIN_2008" or @OSVersion = "WIN_7" Then _ShowStartButton($fShow)
$hTaskBar = _WinAPI_FindWindow("Shell_TrayWnd", "")
If $fShow=0 Then
_WinAPI_ShowWindow($hTaskBar, @SW_SHOW)
Else
_WinAPI_ShowWindow($hTaskBar, @SW_HIDE)
EndIf
EndFunc ;==>_ShowTaskBar
Func _ShowStartButton($fShow )
Local $hTaskBar, $hStartButton
If @OSVersion = "WIN_VISTA" or @OSVersion = "WIN_2008" or @OSVersion = "WIN_7" Then
$hStartButton = _WinAPI_FindWindow("Button", "Start")
Else
$hTaskBar = _WinAPI_FindWindow("Shell_TrayWnd", "")
$hStartButton = ControlGetHandle($hTaskBar, "", "Button1")
EndIf
If $fShow=0 Then
_WinAPI_ShowWindow($hStartButton, @SW_SHOW)
Else
_WinAPI_ShowWindow($hStartButton, @SW_HIDE)
EndIf
EndFunc ;==>

Which "shows" the taskbar, when the mouse moves away from it. It runs this exe

#NoTrayIcon
#Include <WinAPI.au3>
_ShowTaskBar(1)
Func _ShowTaskBar($fShow)
Local $hTaskBar
If @OSVersion = "WIN_VISTA" or @OSVersion = "WIN_2008" or @OSVersion = "WIN_7" Then _ShowStartButton($fShow)
$hTaskBar = _WinAPI_FindWindow("Shell_TrayWnd", "")
If $fShow=0 Then
_WinAPI_ShowWindow($hTaskBar, @SW_SHOW)
Else
_WinAPI_ShowWindow($hTaskBar, @SW_HIDE)
_WinAPI_ShowWindow($hTaskBar, @SW_DISABLE)
EndIf
EndFunc ;==>_ShowTaskBar
Func _ShowStartButton($fShow )
Local $hTaskBar, $hStartButton
If @OSVersion = "WIN_VISTA" or @OSVersion = "WIN_2008" or @OSVersion = "WIN_7" Then
$hStartButton = _WinAPI_FindWindow("Button", "Start")
Else
$hTaskBar = _WinAPI_FindWindow("Shell_TrayWnd", "")
$hStartButton = ControlGetHandle($hTaskBar, "", "Button1")
EndIf
If $fShow=0 Then
_WinAPI_ShowWindow($hStartButton, @SW_SHOW)
Else
_WinAPI_ShowWindow($hStartButton, @SW_HIDE)
_WinAPI_ShowWindow($hStartButton, @SW_DISABLE)
EndIf
EndFunc ;==>

Which hides it. Now the reason why i use these code is cuz for the following images. **Edit though its kinda hard to see in the screenshots if u look closely u can see it :D

But basicly with auto-hide on i get more screen space and with the "off.exe" running u just get the wallpaper, but with auto-hide on and my exe not running You see the little line + bumps at the top of the screen.

Now sometimes when just working on my computer some applications un-hide the taskbar, which is why i need something to detect when this happens and re-hide it :oops:

Edited by IanN1990
Link to comment
Share on other sites

After a bit of searching i found the code above can be replaced with 2 lines, maybe someone else will find this useful :D

Hide taskbar

ControlHide('','', WinGetHandle("[CLASS:Shell_TrayWnd]"))

ControlHide('','', WinGetHandle("[CLASS:Button]"))

Show taskbar

ControlShow('','', WinGetHandle("[CLASS:Shell_TrayWnd]"))

ControlShow('','', WinGetHandle("[CLASS:Button]"))

Still offers the problem the old cold had, where if u close task-manger, the bar reshow itself :oops:

Also i found using WinFlash will make the taskbar active until the icon is clicked, though i dont want a orange/flashing icon all the time :) so i need to find another way to make it active

**Edit i now use

WinSetTrans("[Class:Shell_TrayWnd]", "", 255)

ControlShow('','', WinGetHandle("[CLASS:Button]")) for showing and

WinSetTrans("[Class:Shell_TrayWnd]", "", 0)

ControlHide('','', WinGetHandle("[CLASS:Button]")) for hiding. Has no issues from what i have seen :rip:

Still have not found a way to keep the task-bar active all the time though

**EDIT

I had an idea for keeping the taskbar active 24/7 :D

$hGUI = GUICreate("Flash", 300, 300)
GUISetState()
WinSetState("[Class:AutoIt v3 GUI]", "", @SW_MINIMIZE)
while 1
sleep(500)
If winactive("[Class:Shell_TrayWnd]") Then
  WinSetState("[Class:AutoIt v3 GUI]", "", @SW_HIDE)
Else
  WinSetState("[Class:AutoIt v3 GUI]", "", @SW_SHOW)
  winflash("[Class:AutoIt v3 GUI]")
  EndIf
WEnd

Just something i mocked up for testing, as the task-bar is hidden i wouldnt see the item flashing but when the taskbar is shown it hides it :(

Edited by IanN1990
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...