So now that I have a nice big 23" monitor, I found that I have a lot more usable space. So what I wanted to be able to do is tile my application windows on the screen so I can make the most of that space. Unfortunately, the company I work for still uses XP. So I don't have the Windows 7 snap feature available when working on programming projects.
So here is an AutoHotKey script that allows you to use keyboard shortcuts to arrange windows using WIN + NumberPad key... so for example, WIN + 9 will put the active window in the top-right corner of the screen or WIN + 4 will put the active window in on the left half of the screen. Learn more about AutoHotKey.
#NoEnv
#Persistent
#SingleInstance force
;############################################################################################
; Window Snap - Use WIN + NumPad to snap windows to fill part of the screen
GetTop(Top, Bottom) {
Return Top + Ceil((Bottom - Top) / 2)
}
GetLeft(Left, Right) {
If (Left < 0) {
Return Left + Ceil((Abs(Right) - Left) / 2)
} else {
Return Left + Ceil((Right - Left) / 2)
}
}
GetWidth(Left, Right) {
If (Left < 0) {
Return Ceil((Abs(Right) - Left) / 2)
} else {
Return Ceil((Right - Left) / 2)
}
}
GetHeight(Top, Bottom) {
Return Ceil((Bottom - Top) / 2)
}
#NumPadIns::
#NumPad0::
#0::
SysGet, Count, MonitorCount
SysGet, Primary, MonitorPrimary
MsgBox, Monitor Count:`t%Count%`nPrimary Monitor:`t%Primary%
Loop, %Count%
{
SysGet, Name, MonitorName, %A_Index%
SysGet, Monitor, Monitor, %A_Index%
SysGet, Area, MonitorWorkArea, %A_Index%
MsgBox, Monitor:`t#%A_Index%`nName:`t%Name%`nLeft:`t%MonitorLeft% (%AreaLeft% work)`nTop:`t%MonitorTop% (%AreaTop% work)`nRight:`t%MonitorRight% (%AreaRight% work)`nBottom:`t%MonitorBottom% (%AreaBottom% work)
}
Return
#NumPadPgUp::
#NumPad9::
#9::
WinGetTitle, WinA, A
WinRestore, %WinA%
SysGet, M1, MonitorWorkArea, 1
WinMove, %WinA%,, GetLeft(M1Left, M1Right), M1Top, GetWidth(M1Left, M1Right), GetHeight(M1Top, M1Bottom)
Return
#NumPadUp::
#NumPad8::
#8::
WinGetTitle, WinA, A
WinRestore, %WinA%
SysGet, M1, MonitorWorkArea, 1
WinMove, %WinA%,, M1Left, M1Top, (M1Right - M1Left), GetHeight(M1Top, M1Bottom)
Return
#NumPadHome::
#NumPad7::
#7::
WinGetTitle, WinA, A
WinRestore, %WinA%
SysGet, M1, MonitorWorkArea, 1
WinMove, %WinA%,, M1Left, M1Top, GetWidth(M1Left, M1Right), GetHeight(M1Top, M1Bottom)
Return
#NumPadRight::
#NumPad6::
#6::
WinGetTitle, WinA, A
WinRestore, %WinA%
SysGet, M1, MonitorWorkArea, 1
WinMove, %WinA%,, GetLeft(M1Left, M1Right), M1Top, GetWidth(M1Left, M1Right), (M1Bottom - M1Top)
Return
#NumPadClear::
#NumPad5::
#5::
WinGetTitle, WinA, A
WinRestore, %WinA%
SysGet, M1, MonitorWorkArea, 1
WinMove, %WinA%,, M1Left, M1Top
WinMaximize, %WinA%
Return
#NumPadLeft::
#NumPad4::
#4::
WinGetTitle, WinA, A
WinRestore, %WinA%
SysGet, M1, MonitorWorkArea, 1
WinMove, %WinA%,, M1Left, M1Top, GetWidth(M1Left, M1Right), (M1Bottom - M1Top)
Return
#NumPadPgDn::
#NumPad3::
#3::
WinGetTitle, WinA, A
WinRestore, %WinA%
SysGet, M1, MonitorWorkArea, 1
WinMove, %WinA%,, GetLeft(M1Left, M1Right), GetTop(M1Top, M1Bottom), GetWidth(M1Left, M1Right), GetHeight(M1Top, M1Bottom)
Return
#NumPadDown::
#NumPad2::
#2::
WinGetTitle, WinA, A
WinRestore, %WinA%
SysGet, M1, MonitorWorkArea, 1
WinMove, %WinA%,, M1Left, GetTop(M1Top, M1Bottom), (M1Right - M1Left), GetHeight(M1Top, M1Bottom)
Return
#NumPadEnd::
#NumPad1::
#1::
WinGetTitle, WinA, A
WinRestore, %WinA%
SysGet, M1, MonitorWorkArea, 1
WinMove, %WinA%,, M1Left, GetTop(M1Top, M1Bottom), GetWidth(M1Left, M1Right), GetHeight(M1Top, M1Bottom)
Return
!#NumPadPgUp::
!#NumPad9::
!#9::
WinGetTitle, WinA, A
WinRestore, %WinA%
SysGet, M, MonitorWorkArea, 2
WinMove, %WinA%,, GetLeft(MLeft, MRight), MTop, GetWidth(MLeft, MRight), GetHeight(MTop, MBottom)
Return
!#NumPadUp::
!#NumPad8::
!#8::
WinGetTitle, WinA, A
WinRestore, %WinA%
SysGet, M, MonitorWorkArea, 2
WinMove, %WinA%,, MLeft, MTop, (MRight - MLeft), GetHeight(MTop, MBottom)
Return
!#NumPadHome::
!#NumPad7::
!#7::
WinGetTitle, WinA, A
WinRestore, %WinA%
SysGet, M, MonitorWorkArea, 2
WinMove, %WinA%,, MLeft, MTop, GetWidth(MLeft, MRight), GetHeight(MTop, MBottom)
Return
!#NumPadRight::
!#NumPad6::
!#6::
WinGetTitle, WinA, A
WinRestore, %WinA%
SysGet, M, MonitorWorkArea, 2
WinMove, %WinA%,, GetLeft(MLeft, MRight), MTop, GetWidth(MLeft, MRight), (MBottom - MTop)
Return
!#NumPadClear::
!#NumPad5::
!#5::
WinGetTitle, WinA, A
WinRestore, %WinA%
SysGet, M, MonitorWorkArea, 2
WinMove, %WinA%,, MLeft, MTop
WinMaximize, %WinA%
Return
!#NumPadLeft::
!#NumPad4::
!#4::
WinGetTitle, WinA, A
WinRestore, %WinA%
SysGet, M, MonitorWorkArea, 2
WinMove, %WinA%,, MLeft, MTop, GetWidth(MLeft, MRight), (MBottom - MTop)
Return
!#NumPadPgDn::
!#NumPad3::
!#3::
WinGetTitle, WinA, A
WinRestore, %WinA%
SysGet, M, MonitorWorkArea, 2
WinMove, %WinA%,, GetLeft(MLeft, MRight), GetTop(MTop, MBottom), GetWidth(MLeft, MRight), GetHeight(MTop, MBottom)
Return
!#NumPadDown::
!#NumPad2::
!#2::
WinGetTitle, WinA, A
WinRestore, %WinA%
SysGet, M, MonitorWorkArea, 2
WinMove, %WinA%,, MLeft, GetTop(MTop, MBottom), (MRight - MLeft), GetHeight(MTop, MBottom)
Return
!#NumPadEnd::
!#NumPad1::
!#1::
WinGetTitle, WinA, A
WinRestore, %WinA%
SysGet, M, MonitorWorkArea, 2
WinMove, %WinA%,, MLeft, GetTop(MTop, MBottom), GetWidth(MLeft, MRight), GetHeight(MTop, MBottom)
Return
0 comments:
Post a Comment