Last active
May 29, 2019 10:47
-
-
Save unkn-one/ffd6568dc773e175435c7a86c69818b7 to your computer and use it in GitHub Desktop.
Automatically move taskbar when monitor orientation changes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#NoEnv | |
#SingleInstance force | |
#Persistent | |
OnMessage(0x7E, "WM_DISPLAYCHANGE") | |
return | |
WM_DISPLAYCHANGE(wParam, lParam) { | |
x := lParam & 0xffff ;new horizontal res | |
y := (lParam >> 16) & 0xffff ;new vertical res | |
if (x > y) { | |
TaskbarMove("Left") | |
return | |
} else { | |
TaskbarMove("Bottom") | |
return | |
} | |
} | |
/* | |
** TaskbarMove by JSLover - r.secsrv.net/JSLover - r.secsrv.net/JSLoverAHK | |
** https://github.com/gerdami/AutoHotkey/blob/master/TaskbarMove.ahk | |
*/ | |
TaskbarMove(p_pos) { | |
label:="TaskbarMove_" p_pos | |
WinExist("ahk_class Shell_TrayWnd") | |
SysGet, s, Monitor | |
if (IsLabel(label)) { | |
Goto, %label% | |
} | |
return | |
TaskbarMove_Top: | |
TaskbarMove_Bottom: | |
WinMove(sLeft, s%p_pos%, sRight, 0) | |
return | |
TaskbarMove_Left: | |
TaskbarMove_Right: | |
WinMove(s%p_pos%, sTop, 0, sBottom) | |
return | |
} | |
WinMove(p_x, p_y, p_w="", p_h="", p_hwnd="") { | |
WM_ENTERSIZEMOVE:=0x0231 | |
WM_EXITSIZEMOVE :=0x0232 | |
if (p_hwnd!="") { | |
WinExist("ahk_id " p_hwnd) | |
} | |
SendMessage, WM_ENTERSIZEMOVE | |
;//Tooltip WinMove(%p_x%`, %p_y%`, %p_w%`, %p_h%) | |
WinMove, , , p_x, p_y, p_w, p_h | |
SendMessage, WM_EXITSIZEMOVE | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When testing on Surface Book 2 15 inch I found that the script worked as described whilst the screen was detached from the keyboard. However, when re-attached to the keyboard the taskbar moved again, to the top of the screen. This seems only to happen when the Surface Book is connected to a Surface Dock, and possibly it's related to the Surface Dock being connected to a secondary monitor.