Jump to content

Taskbar problems


Terenz
 Share

Recommended Posts

Hi guys,

I need to hide the taskbar when i open a default folder with autoit. Searching on the forum i have found many method, ControlHide + @SW_HIDE, _WinAPI_FindWindow + @SW_HIDE, WinSetTrans at 0. Everyone work but only in theory, the taskbar is hidden but when i open the folder i have this:

2r5teva.jpg

So the question is:

How to really hide the taskbar and make that space usable?

Thanks for any help

Edited by Terenz

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Link to comment
Share on other sites

Maybe this can Help.

#include <WinAPI.au3>
#include <WindowsConstants.au3>

$iPrevState = LockTaskBar(1)

Func LockTaskBar($iLock)
If @OSVersion <> "WIN_7" Then
        MsgBox(16,"Onyl on Windows 7", "The taskbar can only be locked this way in Windows 7 !")
        Return
    EndIf

    Local $iPrevState = RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced", "TaskbarSizeMove")

    $hTrayWnd = WinGetHandle("[CLASS:Shell_TrayWnd]")
    If _WinAPI_GetClassName($hTrayWnd) <> "Shell_TrayWnd" Then Exit
    If $iPrevState = $iLock Then _SendMessage($hTrayWnd, $WM_COMMAND, 424, 0)
    Return 1-$iPrevState

EndFunc   ;==>LockTaskBar

saludos

Link to comment
Share on other sites

  • Moderators

Terenz,

Search the forum for the DLL call "SetWorkArea" - it tells Windows how big an area it can cover and ususally excludes the taskbar, even if it is hidden. There is another DLL call "GetWorkArea" which will give you the coordinates needed when you reset the size later. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Link to comment
Share on other sites

Hi Melba, that is a workaround of the problem, make the folder bigger instead of use maximize on the folder. I don't belive there isn't a way to hide taskbar like Windows do with auto-hide :sweating:
 
@Danyfirex don't sorry, i'll apprecciate any type of help ;)

Edited by Terenz

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Link to comment
Share on other sites

Ok, the "best-correct method" to automate the taskbar is to use:
SHAppBarMessage
I don't have found an example for add a newstatus to the taskbar, only for retrive information.
My idea was autohide the taskbar ( so the window can be maximized correclty ) using ABM_SETAUTOHIDEBAR and maybe send always hide so if the mouse go over it the taskbar will not appear...this on paper. Someone can help me with this? Thanks

Edited by Terenz

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Link to comment
Share on other sites

For intrested, this is a C# of what i'll try to reproduce

Source: Stackoverflow

[DllImport("user32.dll", CharSet = CharSet.Auto)]
    public static extern IntPtr FindWindow(string strClassName, string strWindowName);

[DllImport("shell32.dll")]
    public static extern UInt32 SHAppBarMessage(UInt32 dwMessage, ref APPBARDATA pData);

public enum AppBarMessages
    {
        New =
        0x00000000,
        Remove =
        0x00000001,
        QueryPos =
        0x00000002,
        SetPos =
        0x00000003,
        GetState =
        0x00000004,
        GetTaskBarPos =
        0x00000005,
        Activate =
        0x00000006,
        GetAutoHideBar =
        0x00000007,
        SetAutoHideBar =
        0x00000008,
        WindowPosChanged =
        0x00000009,
        SetState =
        0x0000000a
    }

    [StructLayout(LayoutKind.Sequential)]
    public struct APPBARDATA
    {
        public UInt32 cbSize;
        public IntPtr hWnd;
        public UInt32 uCallbackMessage;
        public UInt32 uEdge;
        public Rectangle rc;
        public Int32 lParam;
    }

    public enum AppBarStates
    {
        AutoHide =
        0x00000001,
        AlwaysOnTop =
        0x00000002
    }

/// <summary>
    /// Set the Taskbar State option
    /// </summary>
    /// <param name="option">AppBarState to activate</param>
    public void SetTaskbarState(AppBarStates option)
    {
        APPBARDATA msgData = new APPBARDATA();
        msgData.cbSize = (UInt32)Marshal.SizeOf(msgData);
        msgData.hWnd = FindWindow("System_TrayWnd", null);
        msgData.lParam = (Int32)(option);
        SHAppBarMessage((UInt32)AppBarMessages.SetState, ref msgData);
    }

    /// <summary>
    /// Gets the current Taskbar state
    /// </summary>
    /// <returns>current Taskbar state</returns>
    public AppBarStates GetTaskbarState()
    {
        APPBARDATA msgData = new APPBARDATA();
        msgData.cbSize = (UInt32)Marshal.SizeOf(msgData);
        msgData.hWnd = FindWindow("System_TrayWnd", null);
        return (AppBarStates)SHAppBarMessage((UInt32)AppBarMessages.GetState, ref msgData);

When the code above is implemented just set the Taskbar to autohide by:

SetTaskbarState(AppBarStates.AutoHide);

Get the current state by:

AppBarStates currentState = GetTaskbarState();

#END

I have found also a very old library ( 2006 ) in autoit, called >AppBar UDF. Inside there is a Func called _AppbarAutoHideBarSet, but seems not work, maybe need an update?

With my limited knowledge i don't think i can be useful for accomplish this, waiting for someone i'll continue to search and if i'll found something i'll post here.

Edited by Terenz

Nothing is so strong as gentleness. Nothing is so gentle as real strength

 

Link to comment
Share on other sites

For autoHide this work.

Global Const $ABS_AUTOHIDE = 0x1
Global $pabd = DllStructCreate("dword;int;uint;uint;int;int;int;int;int")
DllStructSetData($pabd,1,DllStructGetSize($pabd)) ;cbSize
DllStructSetData($pabd,2,ControlGetHandle("Start","","Shell_TrayWnd")) ;hWnd



DllStructSetData($pabd,9,$ABS_AUTOHIDE) ;????,???????
SHAppBarMessage($ABM_SETSTATE,$pabd) ;??ABM_SETSTATE??????


Func SHAppBarMessage($Message,ByRef $pabd)
$lResult = DllCall("shell32.dll","int","SHAppBarMessage","int",$Message,"ptr",DllStructGetPtr($pabd))
If Not @error Then
If $lResult[0] Then
Return $lResult[0]
EndIf
EndIf
SetError(1)
Return False
EndFunc

saludos

Link to comment
Share on other sites

  • 1 month later...

For autoHide this work.

Global Const $ABS_AUTOHIDE = 0x1
Global $pabd = DllStructCreate("dword;int;uint;uint;int;int;int;int;int")
DllStructSetData($pabd,1,DllStructGetSize($pabd)) ;cbSize
DllStructSetData($pabd,2,ControlGetHandle("Start","","Shell_TrayWnd")) ;hWnd



DllStructSetData($pabd,9,$ABS_AUTOHIDE) ;????,???????
SHAppBarMessage($ABM_SETSTATE,$pabd) ;??ABM_SETSTATE??????


Func SHAppBarMessage($Message,ByRef $pabd)
$lResult = DllCall("shell32.dll","int","SHAppBarMessage","int",$Message,"ptr",DllStructGetPtr($pabd))
If Not @error Then
If $lResult[0] Then
Return $lResult[0]
EndIf
EndIf
SetError(1)
Return False
EndFunc

saludos

 

Won't compile without error.  Below "SHAppBarMessage($ABM_SETSTATE,$pabd)" it says "$ABM_SETSTATE: possibly used before declaration, undeclared global variable.

Link to comment
Share on other sites

  • 9 years later...

Apologizing for bumping an old post, I just want to provide a cleaner snippet, which is more intuitive based on MSDOC's APPBARDATA: https://docs.microsoft.com/en-us/windows/win32/api/shellapi/ns-shellapi-appbardata
 

ToggleTaskbarAutoHide()
MsgBox(262144, '', 'Taskbar autohide toggled')
ToggleTaskbarAutoHide()


Func ToggleTaskbarAutoHide()

    Local Const $ABM_GETSTATE = 0x00000004
    Local Const $ABM_SETSTATE = 0x0000000A
    Local Const $ABS_AUTOHIDE = 0x00000001
    Local Const $ABS_ALWAYSONTOP = 0x00000002

    Local $tAPPBARDATA = DllStructCreate('dword;int;uint;uint;int[4];int')
    DllStructSetData($tAPPBARDATA, 1, DllStructGetSize($tAPPBARDATA))
    DllStructSetData($tAPPBARDATA, 2, WinGetHandle('[CLASS:Shell_TrayWnd]'))

    Local $iCurrentState = DllCall('shell32.dll', 'int', 'SHAppBarMessage', 'dword', $ABM_GETSTATE, 'ptr', DllStructGetPtr($tAPPBARDATA))

    Local $iNewState = $iCurrentState[0] ? $ABS_ALWAYSONTOP : $ABS_AUTOHIDE

    DllStructSetData($tAPPBARDATA, 6, $iNewState)

    DllCall('shell32.dll', 'int', 'SHAppBarMessage', 'dword', $ABM_SETSTATE, 'ptr', DllStructGetPtr($tAPPBARDATA))

EndFunc

 

Edited by sylremo
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...