0 0 0 0


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). Definitely, we can move task bar by using mouse, but I want to move it by a program, or a sort of automated way.

I tried to find Win32 API, but it seems no one does this job.

EDIT: I was surprised by many people's opinion. Let me explain why I wanted it. In my workplace, I'm using dual monitors (resolutions are different), and the taskbar is placed on the left monitor while the primary monitor is the right monitor. However, I often connect to my workplace computer via remote desktop. After the remote connection, the taskbar position is switched. That's why I wanted to make a simple program that can save/restore taskbar's position. Everyday I have to rearrange my taskbar. That's it. I just want it for me.

Best Answer:

I've had some luck with this task in an AutoHotkey script, just in case you don't care about the language used. It uses simulated keystrokes and mouse movements to move your taskbar. I stopped short of automatically unlocking/locking the taskbar.

The hard part was getting it to work reliably. A lot of the code is dedicated to making sure that the taskbar moved. It still doesn't work 100%... it fails like 10% of the time from what I've seen. However, it should be good enough to get you started!

If I ever come back to this script to make it work perfectly, I'll repost here.

Here is the example script (highlighting is a bit odd here, as the language is AHK):

; Move the taskbar
; dspNumber:    number.  device number (primary display is 1, secondary display is 2...)
; edge:         string.  Top, Right, Bottom, or Left
MoveTaskbar(dspNumber, edge)
    OutputDebug MoveTaskbar - called to move taskbar to display #%dspNumber% ("%edge%" edge)
    ; absolute coordinate system
    CoordMode, Mouse, Screen
    ; error checking for dspNumber
    SysGet, numMonitors, MonitorCount
    if (numMonitors<dspNumber)
        OutputDebug MoveTaskbar - [ERROR] target monitor does not exist (dspNumber = "%dspNumber%")
    ; get screen position for target monitor
    SysGet, target, Monitor, %dspNumber%
    oX := 7
    oY := 7
    ; get coordinates for where to move the taskbar
    if (edge = "Top")
        oX := (targetRight-targetLeft)/2
        trgX := oX+targetLeft
        trgY := targetTop+15
    else if (edge = "Right")
        oY := -(targetBottom-targetTop)/2
        trgX := targetRight-15
        trgY := -oY + targetTop
    else if (edge = "Bottom")
        oX := -(targetRight-targetLeft)/2
        trgX := -oX+targetLeft
        trgY := targetBottom-15
    else if (edge = "Left")
        oY := (targetBottom-targetTop)/2
        trgX := targetLeft+15
        trgY := oY+targetTop
        OutputDebug MoveTaskbar - [ERROR] target edge was improperly specified (edge = "%edge%")
    trgX := round(trgX)
    trgY := round(trgY)
    oX := round(oX)
    oY := round(oY)
    OutputDebug MoveTaskbar - target location is (%trgX%,%trgY%)
    MouseGetPos, startX, startY
    OutputDebug MoveTaskbar - mouse is currently at (%startX%,%startY%)
    ; request the move mode (via context menu)
    SendInput #b
    SendInput !+{Space}
    SendInput m
    ; wait for the move mode to be ready
        if A_Cursor = SizeAll
    OutputDebug MoveTaskbar - move mode is ready
    ; start the move mode
    SendInput {Right}   
    ; wait for the move mode to become active for mouse control
        if A_Cursor = Arrow
    OutputDebug MoveTaskbar - move mode is active for mouse control
    ; move taskbar (and making sure it actually does move)
    offset := 7
    count := 0
        ; move the taskbar to the desired location
        OutputDebug MoveTaskbar - attempting to move mouse to (%trgX%,%trgY%)
        MouseMove, %trgX%, %trgY%, 0
        MouseGetPos, mX, mY, win_id
        WinGetClass, win_class, ahk_id %win_id%
        count += 1
        ; if the mouse didn't get where it was supposed to, try again
        If ((mX != trgX) or (mY != trgY))
            OutputDebug MoveTaskbar - mouse didn't get to its destination (currently at (%mX%,%mY%)).  Trying the move again...
        ; if the taskbar hasn't followed yet, wiggle the mouse!
        if (win_class != "Shell_TrayWnd")
            OutputDebug MoveTaskbar - window with class "%win_class%" is under the mouse... wiggling the mouse until the taskbar gets over here
            ;offset := - offset
            trgX -= round(oX/2)
            trgY -= round(oY/2)
            oX := -oX
            oY := -oY
            if count = 50
                OutputDebug, MoveTaskbar - wiggling isn't working, so I'm giving up.
    OutputDebug MoveTaskbar - taskbar successfully moved
    SendInput {Enter}

Copyright © 2011 Dowemo All rights reserved.    Creative Commons   AboutUs