How to programmatically move Windows taskbar?

前端 未结 6 679
无人及你
无人及你 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条回答
  •  隐瞒了意图╮
    2021-02-07 00:27

    I also have this need on Windows 7. Here is my take to do this using autohotkey script:

    ; This script will try to drag and move the taskbar to where the *current* mouse
    ; cursor is
    
    ; 0x111: WM_COMMAND, 424: lock/unlock taskbar, http://www.codeproject.com/KB/miscctrl/Taskbar_Manipulation.aspx
    RegRead, TaskbarLocked, HKEY_CURRENT_USER, SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced, TaskbarSizeMove
    If TaskbarLocked = 0
      SendMessage 0x111, 424, , , ahk_class Shell_TrayWnd   
    
    WinActivate ahk_class Shell_TrayWnd
    MouseGetPos targetX, targetY
    ControlGetPos x, y, w, h, MSTaskListWClass1, ahk_class Shell_TrayWnd
    MouseMove x+1, y+1
    MouseClickDrag Left, x+1, y+1, targetX, targetY, 10
    
    ; often after dragging the taskbar to left or right side of a monitor, even though
    ; there are enough room to show two columns of icons, it will only show one column,
    ; it seems showing or hiding an icon will fix this
    Menu, Tray, NoIcon
    Menu, Tray, Icon
    
    ; lock the taskbar if it was previously locked
    If TaskbarLocked = 0
      SendMessage 0x111, 424, , , ahk_class Shell_TrayWnd   
    

    I have tested this on Windows 7 with classic window theme. To use this, assign a hotkey to call this script, then position mouse cursor to where you want to drag the taskbar to, then press the hotkey.

提交回复
热议问题