0

This autohotkey code works fine to resize the win 7 taskbar when it is on the left position

ResizeTaskbar(170)

ResizeTaskbar(size) {
    pAppBarData := Buffer(48), NumPut("uint", pAppBarData.Size, pAppBarData)
    DllCall("Shell32\SHAppBarMessage", "uint", 0x00000005, "ptr", pAppBarData)
        hTB := WinExist("ahk_class Shell_TrayWnd")
        NumPut("int", -A_ScreenWidth, pAppBarData, 24), NumPut("int", size, pAppBarData, 32)

        SendMessage(0x0214, 2, pAppBarData.Ptr + 24, , hTB), WinMove(0, 0)
}

I want to resize the taskbar when it is in bottom position so I changed the above code to:

ResizeTaskbar(170)

ResizeTaskbar(size) {
    pAppBarData := Buffer(48), NumPut("uint", pAppBarData.Size, pAppBarData)
    DllCall("Shell32\SHAppBarMessage", "uint", 0x00000005, "ptr", pAppBarData)
        hTB := WinExist("ahk_class Shell_TrayWnd")
        NumPut("int", -A_ScreenHeight, pAppBarData, 24), NumPut("int", size, pAppBarData, 32)

        ;https://learn.microsoft.com/en-us/windows/win32/winmsg/wm-sizing
        SendMessage(0x0214, 3, pAppBarData.Ptr + 24, , hTB), WinMove(0, 0)
}

but it does not work, where is the problem?

thank you

1 Answer 1

0

I could not make the autohotkey code to work, but i found a C code that worked after some editing, I posted the source and binary here if someone need it https://github.com/m417z/taskbar-resize/issues/3

// no need to compile 64, compile only 32 version it works fine with win7 64 
// i compile it with en_visual_studio_community_2013_with_update_5_x86_dvd_6816332.iso

#include <windows.h>
#include <shlwapi.h>

void main()
{
    int argc;
    WCHAR **argv = CommandLineToArgvW(GetCommandLine(), &argc);

    if(argv)
    {
        if(argc >= 3)
        {
            BOOL bBottom = lstrcmpi(argv[1], L"-b") == 0;
            BOOL bTop = lstrcmpi(argv[1], L"-t") == 0;
            BOOL bRight = lstrcmpi(argv[1], L"-r") == 0;
            BOOL bLeft = lstrcmpi(argv[1], L"-l") == 0;
            int nMySize = StrToInt(argv[2]);

            HWND hTaskbarWnd = FindWindow(L"Shell_TrayWnd", NULL);
            if(hTaskbarWnd)
            {
                RECT rc;
                GetWindowRect(hTaskbarWnd, &rc);

                if(bBottom) {
                    rc.top = rc.bottom - nMySize;
                    SendMessage(hTaskbarWnd, WM_SIZING, WMSZ_TOP, (LPARAM)&rc);
                    SetWindowPos(hTaskbarWnd, NULL, 0, 0, rc.right - rc.left, nMySize, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
                }
                else if(bTop) {
                    rc.bottom = rc.top + nMySize;
                    SendMessage(hTaskbarWnd, WM_SIZING, WMSZ_BOTTOM, (LPARAM)&rc);
                    SetWindowPos(hTaskbarWnd, NULL, 0, 0, rc.right - rc.left, nMySize, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
                }
                else if(bRight) {
                    rc.left = rc.right - nMySize;
                    SendMessage(hTaskbarWnd, WM_SIZING, WMSZ_LEFT, (LPARAM)&rc);
                    SetWindowPos(hTaskbarWnd, NULL, 0, 0, nMySize, rc.bottom - rc.top, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
                }
                else if(bLeft) {
                    rc.right = rc.left + nMySize;
                    SendMessage(hTaskbarWnd, WM_SIZING, WMSZ_LEFT, (LPARAM)&rc);
                    SetWindowPos(hTaskbarWnd, NULL, 0, 0, nMySize, rc.bottom - rc.top, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
                }
            }
        }

        LocalFree(argv);
    }

    ExitProcess(0);
}

Usage

taskbar_resize.exe (-l|-r|-b|-t) new_size

Description:

-l - The taskbar is on the left.

-r - The taskbar is on the right.

-b - The taskbar is on the bottom.

-t - The taskbar is on the top.

new_size - The new size of the taskbar, in pixels.

NB: for top and bottom positions, you cannot resize to 3 rows from 1 row you have to resize to 2 rows first then resize to 3 rows

the following numbers are based on the taskbar with small icons not the big ones

taskbar_resize.exe -b 60 ===> 1 row
taskbar_resize.exe -b 70 ===> 2 rows
taskbar_resize.exe -b 110 ===> 3 rows
taskbar_resize.exe -b 150 ===> 4 rows
taskbar_resize.exe -b 180 ===> 5 rows
taskbar_resize.exe -b 220 ===> 6 rows
taskbar_resize.exe -b 250 ===> 7 rows

update: I uploaded a compiled version for xp+ if someone need it, here: https://github.com/badrelmers/taskbar-resize/releases/tag/v1

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.