How to programmatically move Windows taskbar?

前端 未结 6 695
无人及你
无人及你 2021-02-06 23:32

I\'d like to know any sort of API or workaround (e.g., script or registry) to move (or resize) Windows taskbar to another position including another monitor (if dual monitors).

6条回答
  •  旧时难觅i
    2021-02-07 00:01

    Thank you for asking this question!

    Its Windows 10 now and i got the same kind of problem where i made a script to switch between a 2 screens setup and only the tv for movies. After switching back to the 2 screens setup, the taskbar is back on the right monitor, just like you experienced.

    I found a solution involving modifying the registry key that defines the taskbar location.

    This is the said key: HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\StuckRects3

    Open the regisrty editor while your taskbar is at the right spot and size (Win+R, type regedit", the enter), then navigate to the key path above. You should find a binary value named "Settings" that looks like this:

    30 00 00 00 fe ff ff ff 02 00 00 00 03 00 00 00 4e 00 00 00 32 00 00 00 80 f8 ff ff b2 01 00 00 be f8 ff ff ea 05 00 00 60 00 00 00 01 00 00 00

    Your numbers may vary, but it doesn't matter. Simply click on file>export action in the menu once you navigated to the value, then use the file->export option from the top menu, and and save the .reg file in your system forlder (C:\Windows\System32). Make sure the export range is set to "Selected Branch" so only this value is affected. This will create a registry script that will restore the exact position of your taskbar.

    However, if you just use the "merge" option on your script, you won't see the change since you will need to restart the explorer.exe process. To achieve this, you can simply make a batch script in noptepad looking like this:

    @echo off
    %windir%\system32\regedit.exe /s file.reg
    taskkill /f /im explorer.exe
    start explorer.exe
    end
    

    Simply replace in the 2nd line the "file.reg" by the complete file name of the .reg script you previously created, then save the file as a ".bat".

    Running this script as an admin will reset the taskbar to where it should be. You will see the ui flashing briefly, since the taskbar and desktop will reset.

    You could call this script from a Task, or make a shortcut that is set to run as admin to make it even easier!

    I hope this answer reaches you, even if is is a "little" late XD

    Your Welcome!

提交回复
热议问题