This Script should automatically Map Out your Monitor Configuration, regardless of:
- Number of Monitors
- Resolution of Monitors
- Monitor Layout (Positioning)
- Monitor Numbering (the Numbering Windows assigns to Monitors)
- If the Zoom setting of Monitors are not all the same, this Script will do wonky things
- If a Window is Maximized, then moved to another Monitor and "UnMaximized" (Restored) by double clicking on the Titlebar, the Window will appear in the First initial Monitor.
- Resize Active Window to Left and Right Half of Current Monitor
- When Active Window is already resized to Left or Right Half of Monitor, move Active Window the next Monitor over
- Move Active Window to Previous or Next Monitor
- Move Active Window to Upper or Lower Monitor (When Monitors are stacked up, when there are multiple Rows of Monitors)
- Resize Active Window to any one of the 4 Quadrants of Current Monitor
- When Active Window is already resized in a Quadrant of Monitor, move Active Window the next Upper / Lower Quadrant of Monitor
- Maximize Active Window
- Minimize Active Window
- Quick Minimize Window under Mouse Cursor (Activates Window before Minimizing)
- Quick Close Window under Mouse Cursor (Activates Window before Minimizing)
- When resizing Active Window to Left or Right Half of the Monitor, the Script will take into consideration the Taskbar and Resize the Active Window accordingly.
- If the Active Window is at Full Height on Current Monitor, when moving it to another Monitor, it will stay at Full Height, regardless of Monitor Resolution or Work Area.
- If there are Multiple Monitor Rows, when Moving the Active Window to Left or Right Monitor past the First or Last Monitor, the Active Window will wrap around to the Next or Previous Row of Monitors (Next Upper or Lower Row).
- When Moving Active Window Up or Down, past the Top or Lowest Monitors, the Active Window will wrap around, staying in the same Column.
- If there are gaps in Rows or Columns of Monitors, the Script will skip the gaps and continue to the Next Monitor of the same Row / Column.
- There are options to Resize specific Programs to 3/4 of the height instead of Full Height of Side of Monitor (E.g. Skype, Calculator, etc.)
- The Monitors must be perfectly Aligned. In my experience, Windows 10 tends to add small misalignments. I use DisplayFusion to align my Monitors, it’s really great.
- By default, to constitute a Row, the Monitors should be aligned with their Top Boundaries. If your Monitors don't all have the same resolution, and your Monitors are aligned with their Bottom Boundaries, the Lines of Code to change are indicated in the Script “Option ➔ Bottom of Row Alignment”.
- Automatic Mapping of your Monitor Configuration is done on Script Startup. If you change your Monitor Configuration, you must restart the Script for the Script to work properly.
- I could have made the script to retrieve all the variables on a HotKey Keypress (Number of Monitors, Monitor Dimensions, Monitor Positioning, etc.) but I figured loading all the variables on script start would speed up execution and eliminate unnecessary CPU use.
- Moving a Maximized Window to another Monitor does not Resize the Active Window to take into account the Taskbar. I chose not to Restore the Active Window before moving it because that produces a very slow and clunky Move.
- There are two Mapping procedures in the Script: One for Horizontal Movement and One for Vertical Movement. I chose two different processes for each.
- Horizontal Movement is Mapped with 1D Arrays and Monitors are retrieved by a Sequential Number. Monitors are Organized and Numbered from First to Last, from Left to Right continuously through every Row.
- Vertical Movement is Mapped with 2D Arrays and Monitors are retrieved by Column and Row Number. The Monitors are Organized and Numbered from First to Last, from Top to Bottom, in each distinct Column.
- I could have used only one process, using only 2D Arrays to retrieve Monitors by Column and Row Number. I started off with 1D Arrays and realized I couldn’t pull off Vertical Movement without 2D Arrays, then went on to integrate 3D Arrays for Quadrant Movement.
Also, I’m not a Programmer by trade, the Code can be more efficient of course. Some Feedback that was received on the code was: "Good Lord, I know everyone's first script is bad". Lol, all things considered, I think it's useful feedback. The point is, the code works! . I'm open to any feedback for improvements. One obvious item of improvement is implementing Object oriented programming, which I still have to learn.
Hope you Enjoy the Script!
Cheers!
Code: Select all
; *********************************************************************************
; Automatic Mapping of All Monitors, Move & Resize Windows -START-
; *********************************************************************************
; Initialization of Arrays used
; Variables used for Temporary Monitor Number used to later organize Monitors in Ascending Order
; (1D Arrays)
MonTopTemp := []
MonBtmTemp := []
MonLftTemp := []
MonRgtTemp := []
; Variables used for Definitive Monitor Number in Ascending Order
; (1D Arrays)
MonTop := []
MonBtm := []
MonLft := []
MonRgt := []
; Variables used for Monitor Dimensions for Resizing to Half or Monitor and for Moving to another Monitor
; (1D Arrays)
MonHlfLft := []
MonHlfRgt := []
MonWdt := []
MonHlfWdt := []
MonHgt := []
; Variables of Definitive Monitor Number used to Move Windows Up and Down between Rows
; (2D Arrays)
MtxTop := []
MtxBtm := []
MtxLft := []
MtxRgt := []
MtxWdt := []
MtxHgt := []
MtxLstRow := []
MtxRowQty := []
Col_RowQty := []
; Variables used for Monitor Dimensions for Resizing to Quadrant of Monitor per Monitor Number
; (2D Arrays)
MonQdrTop := []
MonQdrLft := []
MonQdrBtm := []
MonQdrRgt := []
MonQdrWdt := []
MonQdrHgt := []
; Variables used for Monitor Dimensions for Resizing to Quadrant of Monitor per Column
; (3D Arrays)
MtxQdrTop := []
MtxQdrLft := []
MtxQdrBtm := []
MtxQdrRgt := []
MtxQdrWdt := []
MtxQdrHgt := []
; Variables used for Row Alignment with Bottom of Monitors
MonDIMBtmT := []
; Retrieve the Quantity of Monitors connected to system
SysGet, MonQty, MonitorCount
; Retrieve Coordinates and Dimensions of each Monitor
Loop, %MonQty%
{
SysGet, MonWRKA, MonitorWorkArea, %A_Index%
SysGet, MonDIM, Monitor, %A_Index%
MonTopTemp[A_Index] := MonWRKATop
MonBtmTemp[A_Index] := MonWRKABottom
MonLftTemp[A_Index] := MonWRKALeft
MonRgtTemp[A_Index] := MonWRKARight
RowCntTemp = %RowCntTemp%, %MonWRKATop%
ColCntTemp = %ColCntTemp%, %MonWRKALeft%
; Variables used for Row Alignment with Bottom of Monitors
; Options to Define Rows with Bottom of Monitors are Indicated Further in the Script
MonDIMBtmT[A_Index] := MonDIMBottom
RowCntBtmT = %RowCntBtmT%, %MonDIMBottom%
}
; Trim the first character (a comma ",")
StringTrimLeft, RowCnt, RowCntTemp, 1
StringTrimLeft, ColCnt, ColCntTemp, 1
; Bottom of Row Alignment
StringTrimLeft, RowBtmCnt, RowCntBtmT, 1
; List out each unique value of Row and Column, defining boundaries
Sort RowCnt, N U D,
Sort ColCnt, N U D,
; Bottom of Row Alignment
Sort RowBtmCnt, N U D,
; Count the number of Rows and Columns
Loop, Parse, RowCnt, `,
{
RowQty := A_Index
}
Loop, Parse, ColCnt, `,
{
ColQty := A_Index
}
; Bottom of Row Alignment
Loop, Parse, RowBtmCnt, `,
{
RowBtmQty := A_Index
}
; Separates each value of Row and Column into an Array Variable
RowValues := StrSplit(RowCnt, ",", " ")
ColValues := StrSplit(ColCnt, ",", " ")
; Bottom of Row Alignment
RowBtmValues := StrSplit(RowBtmCnt, ",", " ")
; ***** Monitor Mapping Initialization *****
; After counting how many Rows and Columns there are, the script will verify if
; there is a Monitor in each of the Rows/Columns Positions. If there is a gap
; (no Monitor in a Row/Column), the Space should not register in the Mapping
; Counter to Assign Monitor Number, from Top Left to Bottom Right
MonOrdr := 1
Loop, %RowQty%
; ******************************************************************
; Option ➔ Bottom of Row Alignment / Put in Comments the Line above
; Loop, %RowBtmQty%
; ******************************************************************
{
; Keep the current Row in Memory
RowPosA_Index := A_Index
Loop, %ColQty%
{
; Keep the current Column in Memory
ColPosA_Index := A_Index
Loop, %MonQty%
{
; Keep the current Monitor Number in Memory
MonNrA_Index := A_Index
If (ColValues[ColPosA_Index] == MonLftTemp[MonNrA_Index] AND RowValues[RowPosA_Index] == MonTopTemp[MonNrA_Index])
; *********************************************************************************************************************
; Option ➔ Bottom of Row Alignment / Put in Comments the Line above
; If (ColValues[ColPosA_Index] == MonLftTemp[MonNrA_Index] AND RowBtmValues[RowPosA_Index] == MonDIMBtmT[MonNrA_Index])
; *********************************************************************************************************************
{
; Assign COORDINATES and DIMENSIONS of Monitors in Order, per MONITOR NUMBER, from Top Left to Bottom Right
MonTop[MonOrdr] := MonTopTemp[MonNrA_Index]
MonLft[MonOrdr] := MonLftTemp[MonNrA_Index]
MonBtm[MonOrdr] := MonBtmTemp[MonNrA_Index]
MonRgt[MonOrdr] := MonRgtTemp[MonNrA_Index]
; Calculate COORDINATES and DIMENSIONS, per MONITOR NUMBER, to move Window to HALF OF MONITOR and to Another Monitor
MonHlfLft[MonOrdr] := MonLft[MonOrdr]
MonHlfRgt[MonOrdr] := Floor((MonLft[MonOrdr] + MonRgt[MonOrdr]) / 2)
MonWdt[MonOrdr] := MonRgt[MonOrdr] - MonLft[MonOrdr]
MonHlfWdt[MonOrdr] := Floor((MonRgt[MonOrdr] - MonLft[MonOrdr]) / 2)
MonHgt[MonOrdr] := MonBtm[MonOrdr] - MonTop[MonOrdr]
; ***** For Each Monitor Found, Assign Coordinates and Dimensions to 4 Quadrants *****
; Quadrant Q1 of Current Monitor: TOP LEFT
MonQdrTop[MonOrdr, 1] := MonTopTemp[MonNrA_Index]
MonQdrLft[MonOrdr, 1] := MonLftTemp[MonNrA_Index]
MonQdrBtm[MonOrdr, 1] := Floor(MonBtmTemp[MonNrA_Index] / 2)
MonQdrRgt[MonOrdr, 1] := Floor(MonRgtTemp[MonNrA_Index] / 2)
MonQdrWdt[MonOrdr, 1] := Floor((MonRgtTemp[MonNrA_Index] - MonLftTemp[MonNrA_Index]) / 2)
MonQdrHgt[MonOrdr, 1] := Floor((MonBtmTemp[MonNrA_Index] - MonTopTemp[MonNrA_Index]) / 2)
; Quadrant Q2 of Current Monitor: BOTTOM LEFT
MonQdrTop[MonOrdr, 2] := Floor(MonTopTemp[MonNrA_Index] + (MonBtmTemp[MonNrA_Index] - MonTopTemp[MonNrA_Index]) / 2)
MonQdrLft[MonOrdr, 2] := MonLftTemp[MonNrA_Index]
MonQdrBtm[MonOrdr, 2] := MonBtmTemp[MonNrA_Index]
MonQdrRgt[MonOrdr, 2] := Floor(MonRgtTemp[MonNrA_Index] / 2)
MonQdrWdt[MonOrdr, 2] := Floor((MonRgtTemp[MonNrA_Index] - MonLftTemp[MonNrA_Index]) / 2)
MonQdrHgt[MonOrdr, 2] := Floor((MonBtmTemp[MonNrA_Index] - MonTopTemp[MonNrA_Index]) / 2)
; Quadrant Q3 of Current Monitor: TOP RIGHT
MonQdrTop[MonOrdr, 3] := MonTopTemp[MonNrA_Index]
MonQdrLft[MonOrdr, 3] := Floor(MonLftTemp[MonNrA_Index] + (MonRgtTemp[MonNrA_Index] - MonLftTemp[MonNrA_Index]) / 2)
MonQdrBtm[MonOrdr, 3] := Floor(MonBtmTemp[MonNrA_Index] / 2)
MonQdrRgt[MonOrdr, 3] := MonRgtTemp[MonNrA_Index]
MonQdrWdt[MonOrdr, 3] := Floor((MonRgtTemp[MonNrA_Index] - MonLftTemp[MonNrA_Index]) / 2)
MonQdrHgt[MonOrdr, 3] := Floor((MonBtmTemp[MonNrA_Index] - MonTopTemp[MonNrA_Index]) / 2)
; Quadrant Q4 of Current Monitor: BOTTOM RIGHT
MonQdrTop[MonOrdr, 4] := Floor(MonTopTemp[MonNrA_Index] + (MonBtmTemp[MonNrA_Index] - MonTopTemp[MonNrA_Index]) / 2)
MonQdrLft[MonOrdr, 4] := Floor(MonLftTemp[MonNrA_Index] + (MonRgtTemp[MonNrA_Index] - MonLftTemp[MonNrA_Index]) / 2)
MonQdrBtm[MonOrdr, 4] := MonBtmTemp[MonNrA_Index]
MonQdrRgt[MonOrdr, 4] := MonRgtTemp[MonNrA_Index]
MonQdrWdt[MonOrdr, 4] := Floor((MonRgtTemp[MonNrA_Index] - MonLftTemp[MonNrA_Index]) / 2)
MonQdrHgt[MonOrdr, 4] := Floor((MonBtmTemp[MonNrA_Index] - MonTopTemp[MonNrA_Index]) / 2)
; ****************************************************************************
; When a Monitor is found at this ROW and COLUMN Position, increment Count for Next Monitor
MonOrdr += 1
; Once Matching Monitor Found, Skip to Next Column
Break
}
}
}
}
; ***** Monitor Mapping Initialization *****
; This part of the Script will Organize Monitors in Order, from Top to Bottom
Loop, %ColQty%
{
ColPosA_Index := A_Index
; On every new Column, Start Counting Rows at 1
VrtMonOrdr := 1
Loop, %RowQty%
; ******************************************************************
; Option ➔ Bottom of Row Alignment / Put in Comments the Line above
; Loop, %RowBtmQty%
; ******************************************************************
{
RowPosA_Index := A_Index
Loop, %MonQty%
{
VrtMonNrA_Index := A_Index
If (ColValues[ColPosA_Index] == MonLftTemp[VrtMonNrA_Index] AND RowValues[RowPosA_Index] == MonTopTemp[VrtMonNrA_Index])
; ***************************************************************************************************************************
; Option ➔ Bottom of Row Alignment / Put in Comments the Line above
; If (ColValues[ColPosA_Index] == MonLftTemp[VrtMonNrA_Index] AND RowBtmValues[RowPosA_Index] == MonDIMBtmT[VrtMonNrA_Index])
; ***************************************************************************************************************************
{
; Assign COORDINATES and DIMENSIONS of Monitors in Order, per ROW and COLUMN COLUMN (MATRIX), from Top to Bottom for each Column
MtxTop[VrtMonOrdr, ColPosA_Index] := MonTopTemp[VrtMonNrA_Index]
MtxLft[VrtMonOrdr, ColPosA_Index] := MonLftTemp[VrtMonNrA_Index]
MtxBtm[VrtMonOrdr, ColPosA_Index] := MonBtmTemp[VrtMonNrA_Index]
MtxRgt[VrtMonOrdr, ColPosA_Index] := MonRgtTemp[VrtMonNrA_Index]
; Calculate COORDINATES and DIMENSIONS, per ROW and COLUMN COLUMN (MATRIX), to move Window to Another Monitor
MtxWdt[VrtMonOrdr, ColPosA_Index] := MonRgtTemp[VrtMonNrA_Index] - MonLftTemp[VrtMonNrA_Index]
MtxHgt[VrtMonOrdr, ColPosA_Index] := MonBtmTemp[VrtMonNrA_Index] - MonTopTemp[VrtMonNrA_Index]
; ***** For Each Monitor Found, Assign Coordinates and Dimensions to 4 Quadrants *****
; Quadrant Q1 of Current Monitor: TOP LEFT
; Floor Function to be used in case there is a division of an odd number which would leave a "0.5". Comparisons (Full Height and Quadrants) do not work without it.
MtxQdrTop[VrtMonOrdr, ColPosA_Index, 1] := MonTopTemp[VrtMonNrA_Index]
MtxQdrLft[VrtMonOrdr, ColPosA_Index, 1] := MonLftTemp[VrtMonNrA_Index]
MtxQdrBtm[VrtMonOrdr, ColPosA_Index, 1] := Floor(MonBtmTemp[VrtMonNrA_Index] / 2)
MtxQdrRgt[VrtMonOrdr, ColPosA_Index, 1] := Floor(MonRgtTemp[VrtMonNrA_Index] / 2)
MtxQdrWdt[VrtMonOrdr, ColPosA_Index, 1] := Floor((MonRgtTemp[VrtMonNrA_Index] - MonLftTemp[VrtMonNrA_Index]) / 2)
MtxQdrHgt[VrtMonOrdr, ColPosA_Index, 1] := Floor((MonBtmTemp[VrtMonNrA_Index] - MonTopTemp[VrtMonNrA_Index]) / 2)
; Quadrant Q2 of Current Monitor: BOTTOM LEFT
MtxQdrTop[VrtMonOrdr, ColPosA_Index, 2] := Floor(MonTopTemp[VrtMonNrA_Index] + (MonBtmTemp[VrtMonNrA_Index] - MonTopTemp[VrtMonNrA_Index]) / 2)
MtxQdrLft[VrtMonOrdr, ColPosA_Index, 2] := MonLftTemp[VrtMonNrA_Index]
MtxQdrBtm[VrtMonOrdr, ColPosA_Index, 2] := MonBtmTemp[VrtMonNrA_Index]
MtxQdrRgt[VrtMonOrdr, ColPosA_Index, 2] := Floor(MonRgtTemp[VrtMonNrA_Index] / 2)
MtxQdrWdt[VrtMonOrdr, ColPosA_Index, 2] := Floor((MonRgtTemp[VrtMonNrA_Index] - MonLftTemp[VrtMonNrA_Index]) / 2)
MtxQdrHgt[VrtMonOrdr, ColPosA_Index, 2] := Floor((MonBtmTemp[VrtMonNrA_Index] - MonTopTemp[VrtMonNrA_Index]) / 2)
; Quadrant Q3 of Current Monitor: TOP RIGHT
MtxQdrTop[VrtMonOrdr, ColPosA_Index, 3] := MonTopTemp[VrtMonNrA_Index]
MtxQdrLft[VrtMonOrdr, ColPosA_Index, 3] := Floor(MonLftTemp[VrtMonNrA_Index] + (MonRgtTemp[VrtMonNrA_Index] - MonLftTemp[VrtMonNrA_Index]) / 2)
MtxQdrBtm[VrtMonOrdr, ColPosA_Index, 3] := Floor(MonBtmTemp[VrtMonNrA_Index] / 2)
MtxQdrRgt[VrtMonOrdr, ColPosA_Index, 3] := MonRgtTemp[VrtMonNrA_Index]
MtxQdrWdt[VrtMonOrdr, ColPosA_Index, 3] := Floor((MonRgtTemp[VrtMonNrA_Index] - MonLftTemp[VrtMonNrA_Index]) / 2)
MtxQdrHgt[VrtMonOrdr, ColPosA_Index, 3] := Floor((MonBtmTemp[VrtMonNrA_Index] - MonTopTemp[VrtMonNrA_Index]) / 2)
; Quadrant Q4 of Current Monitor: BOTTOM RIGHT
MtxQdrTop[VrtMonOrdr, ColPosA_Index, 4] := Floor(MonTopTemp[VrtMonNrA_Index] + (MonBtmTemp[VrtMonNrA_Index] - MonTopTemp[VrtMonNrA_Index]) / 2)
MtxQdrLft[VrtMonOrdr, ColPosA_Index, 4] := Floor(MonLftTemp[VrtMonNrA_Index] + (MonRgtTemp[VrtMonNrA_Index] - MonLftTemp[VrtMonNrA_Index]) / 2)
MtxQdrBtm[VrtMonOrdr, ColPosA_Index, 4] := MonBtmTemp[VrtMonNrA_Index]
MtxQdrRgt[VrtMonOrdr, ColPosA_Index, 4] := MonRgtTemp[VrtMonNrA_Index]
MtxQdrWdt[VrtMonOrdr, ColPosA_Index, 4] := Floor((MonRgtTemp[VrtMonNrA_Index] - MonLftTemp[VrtMonNrA_Index]) / 2)
MtxQdrHgt[VrtMonOrdr, ColPosA_Index, 4] := Floor((MonBtmTemp[VrtMonNrA_Index] - MonTopTemp[VrtMonNrA_Index]) / 2)
; ****************************************************************************
; Assign Numbering to Monitor on this Column
Col_RowQty[ColPosA_Index] := VrtMonOrdr
; When a Monitor is found at this ROW and COLUMN Position, increment Count for Next Monitor in this Column
VrtMonOrdr += 1
; Once Matching Monitor Found, Skip to Next Row
Break
}
}
}
}
; HOTKEY
; **************
; Move and Resize Active Window to LEFT HALF of Current Monitor
![::
!NumPad4::
#^!+NumPad4::
#^!+NumPadLeft::
#^!NumPadLeft::
!LButton::
LftHlfSub:
{
; If Focus is on an Exluded Program (I.e.Desktop), Ignore this HotKey
GoSub, ExcludPrgrm
If (IgnorePrgrm == True)
{
Return
}
; Retrieve Coordinates, Dimensions, Min/Max State, Process Name and Title of Active Window
WinGetPos, WinLft, WinTop, WinWdt, WinHgt, A
WinGet, WinMMax, MinMax, A
WinGet, PNameHlfLft, ProcessName, A
WinGetTitle, TNameHlfLft, A
; Add Correction Factor per Program + Find in which Monitor Active Window is located
GoSub, CrctnFctr
; Retrieves on which Monitor Number the Active Window is on
GoSub, WinCurntMon
; If Window is Maximized, "UnMaximize" it
If (WinMMax == 1)
{
WinRestore, A
}
; If Active Window is a Program I don't want to Resize to Half of the Monitor
If (PNameHlfLft == "lync.exe" OR (PNameHlfLft == "vlc.exe" AND TNameHlfLft ~= "Playlist") OR PNameHlfLft == "slack.exe" OR (PNameHlfLft == "ApplicationFrameHost.exe" AND TNameHlfLft ~= "Calculator"))
{
; Programs that will Resize to 416 Pixels Width (Minimum possible Width of Skype)
If (PNameHlfLft == "vlc.exe" AND TNameHlfLft ~= "Playlist")
{
NrwWdt := 416
}
; Other Programs that will keep their Original Width
Else
{
NrwWdt := WinWdt
}
; If Active Window is already Resized and Located on Left Side of the Current Monitor, Move Active Window to Right Side of Previous Monitor
If (WinLft == MonLft[OnMonitor] + HrzCrctn AND WinTop == MonTop[OnMonitor])
{
; If Active Window is already Resized on Left Side of Monitor #1, Move Window to Right Side of Last Monitor
If (OnMonitor == 1)
{
WinMove, A, , MonRgt[MonQty] - NrwWdt - HrzCrctn, MonTop[MonQty], NrwWdt, (MonHgt[MonQty] * 3 / 4) + HgtCrctn
Return
}
; If Active Window is already Resized on Left Side of Current Monitor, Move Window to Right Side of Previous Monitor
Else
{
WinMove, A, , MonRgt[OnMonitor - 1] - NrwWdt - HrzCrctn, MonTop[OnMonitor - 1], NrwWdt, (MonHgt[OnMonitor - 1] * 3 / 4) + HgtCrctn
Return
}
}
; Move and Resize Active Window to Left Side of Current Monitor
Else
{
WinMove, A, , MonLft[OnMonitor] + HrzCrctn, MonTop[OnMonitor], NrwWdt, (MonHgt[OnMonitor] * 3 / 4) + HgtCrctn
Return
}
}
; If Active Window is already Resized and Located on Left Half of the Current Monitor, Move Active Window to Right Half of Previous Monitor
If (WinLft == MonLft[OnMonitor] + HrzCrctn AND WinTop == MonTop[OnMonitor] AND WinWdt == MonHlfWdt[OnMonitor] + WdtCrctn AND WinHgt == MonHgt[OnMonitor] + HgtCrctn)
{
; If Active Window is already Resized on Left Half of Monitor #1, Move Window to Right Half of Last Monitor
If (OnMonitor == 1)
{
WinMove, A, , MonHlfRgt[MonQty] + HrzCrctn, MonTop[MonQty], MonHlfWdt[MonQty] + WdtCrctn, MonHgt[MonQty] + HgtCrctn
Return
}
; If Active Window is already Resized on Left Half of Current Monitor, Move Window to Right Half of Previous Monitor
Else
{
WinMove, A, , MonHlfRgt[OnMonitor - 1] + HrzCrctn, MonTop[OnMonitor - 1], MonHlfWdt[OnMonitor - 1] + WdtCrctn, MonHgt[OnMonitor - 1] + HgtCrctn
Return
}
}
; Move and Resize Active Window to Left Half of Current Monitor
Else
{
WinMove, A, , MonLft[OnMonitor] + HrzCrctn, MonTop[OnMonitor], MonHlfWdt[OnMonitor] + WdtCrctn, MonHgt[OnMonitor] + HgtCrctn
Return
}
}
; HOTKEY
; **************
; Move and Resize Active Window to RIGHT HALF of Current Monitor
!]::
!NumPad6::
#^!+NumPad6::
#^!+NumPadRight::
#^!NumPadRight::
!RButton::
RgtHlfSub:
{
GoSub, ExcludPrgrm
If (IgnorePrgrm == True)
{
Return
}
WinGetPos, WinLft, WinTop, WinWdt, WinHgt, A
WinGet, WinMMax, MinMax, A
WinGet, PNameHlfRgt, ProcessName, A
WinGetTitle, TNameHlfRgt, A
GoSub, CrctnFctr
GoSub, WinCurntMon
If (WinMMax == 1)
{
WinRestore, A
}
; If Active Window is a Program I don't want to Resize to Half of the Monitor
If (PNameHlfRgt == "lync.exe" OR (PNameHlfRgt == "vlc.exe" AND TNameHlfRgt ~= "Playlist") OR PNameHlfRgt == "slack.exe" OR (PNameHlfRgt == "ApplicationFrameHost.exe" AND TNameHlfRgt ~= "Calculator"))
{
If (PNameHlfLft == "vlc.exe" AND TNameHlfLft ~= "Playlist")
{
NrwWdt := 416
}
Else
{
NrwWdt := WinWdt
}
If (WinLft == MonRgt[OnMonitor] - WinWdt - HrzCrctn AND WinTop == MonTop[OnMonitor])
{
If (OnMonitor == MonQty)
{
WinMove, A, , MonLft[1] + HrzCrctn, MonTop[1], NrwWdt, (MonHgt[1] * 3 / 4) + HgtCrctn
Return
}
Else
{
WinMove, A, , MonLft[OnMonitor + 1] + HrzCrctn, MonTop[OnMonitor + 1], NrwWdt, (MonHgt[OnMonitor + 1] * 3 / 4) + HgtCrctn
Return
}
}
Else
{
WinMove, A, ,MonRgt[OnMonitor] - NrwWdt - HrzCrctn , MonTop[OnMonitor], NrwWdt, (MonHgt[OnMonitor] * 3 / 4) + HgtCrctn
Return
}
}
Loop, %MonQty%
{
If (OnMonitor == A_Index)
{
If (WinLft == MonHlfRgt[A_Index] + HrzCrctn AND WinTop == MonTop[A_Index] AND WinWdt == MonHlfWdt[A_Index] + WdtCrctn AND WinHgt == MonHgt[A_Index] + HgtCrctn)
{
; If Active Window is already Resized on Right Half of Last Monitor, Move Window to Left Half of Monitor #1
If (A_Index == MonQty)
{
WinMove, A, , MonHlfLft[1] + HrzCrctn, MonTop[1], MonHlfWdt[1] + WdtCrctn, MonHgt[1] + HgtCrctn
Return
}
Else
{
WinMove, A, , MonHlfLft[A_Index + 1] + HrzCrctn, MonTop[A_Index + 1], MonHlfWdt[A_Index + 1] + WdtCrctn, MonHgt[A_Index + 1] + HgtCrctn
Return
}
}
Else
{
WinMove, A, , MonHlfRgt[A_Index] + HrzCrctn, MonTop[A_Index], MonHlfWdt[A_Index] + WdtCrctn, MonHgt[A_Index] + HgtCrctn
Return
}
}
}
}
; HOTKEY
; **************
; Move Active Window to PREVIOUS Monitor
!NumPadLeft::
{
If (!GetKeyState("NumLock", "T"))
{
GoSub, LftHlfSub
Return
}
}
!+[::
!+NumPad4::
!+NumPadLeft::
!+LButton::
{
; If Focus is on an Exluded Program (I.e.Desktop), Ignore this HotKey
GoSub, ExcludPrgrm
If (IgnorePrgrm == True)
{
Return
}
; If there is only 1 Monitor, Ignore this HotKey
WinGetClass, CNamePrvMon, A
If (MonQty == 1)
{
GoSub, PrevQdr
Return
}
; Retrieve Coordinates and Dimensions of Active Window
WinGetPos, WinHrz, WinVrt, WinWdt, WinHgt, A
GoSub, WinCurntMon
GoSub, WinCurntQdr
GoSub, CrctnFctr
WinGet, WinMMax, MinMax, A
; Calculates difference between Top Left corner of the Active Window and Top Left corner of Current Monitor
WinMovCrctnLft := WinHrz - MonLft[OnMonitor]
WinMovCrctnTop := WinVrt - MonTop[OnMonitor]
; If Active Window is Full Vertical Height on Current Monitor, keep Full Vertical Height on PREVIOUS Monitor, regardless of difference in Monitor Height
If ((WinVrt == MonTop[OnMonitor] AND WinHgt == MonHgt[OnMonitor] + HgtCrctn) OR WinMMax == 1)
{
; If Active Window is Located on Monitor #1, Move Active Window to LAST Monitor (Keep Full Window Height)
If (OnMonitor == 1)
{
WinMove, A, , MonLft[MonQty] + WinMovCrctnLft, MonTop[MonQty], WinWdt, MonHgt[MonQty] + HgtCrctn
Return
}
; Move Active Window to PREVIOUS Monitor (Keep Full Window Height)
Else
{
WinMove, A, , MonLft[OnMonitor - 1] + WinMovCrctnLft, MonTop[OnMonitor - 1], WinWdt, MonHgt[OnMonitor - 1] + HgtCrctn
Return
}
}
; If Active Window is Located in a Quadrant on Current Monitor, Move and Resize Active Window to same Quadrant on PREVIOUS Monitor, regardless of Work Area
Else If (OnQuadrant == 1 OR OnQuadrant == 2 OR OnQuadrant == 3 OR OnQuadrant == 4)
{
; If Active Window is Located in a Quadrant on Monitor #1, Move and Resize Active Window to same Quadrant on LAST Monitor, regardless of Work Area
If (OnMonitor == 1)
{
WinMove, A, , MonQdrLft[MonQty, OnQuadrant] + HrzCrctn, MonQdrTop[MonQty, OnQuadrant], MonQdrWdt[MonQty, OnQuadrant] + WdtCrctn, MonQdrHgt[MonQty, OnQuadrant] + HgtCrctn
Return
}
; Move and Resize Active Window to same Quadrant on PREVIOUS Monitor, regardless of Work Area
Else
{
WinMove, A, , MonQdrLft[OnMonitor - 1, OnQuadrant] + HrzCrctn, MonQdrTop[OnMonitor - 1, OnQuadrant], MonQdrWdt[OnMonitor - 1, OnQuadrant] + WdtCrctn, MonQdrHgt[OnMonitor - 1, OnQuadrant] + HgtCrctn
Return
}
}
; Move Active Window to Previous Monitor, Regardless of Window Height
Else
{
; If Active Window is Located on Monitor #1, Move Active Window to Last Monitor
If (OnMonitor == 1)
{
WinMove, A, , MonLft[MonQty] + WinMovCrctnLft, MonTop[MonQty] + WinMovCrctnTop, WinWdt, WinHgt
Return
}
; Move Active Window to Previous Monitor
Else
{
WinMove, A, , MonLft[OnMonitor - 1] + WinMovCrctnLft, MonTop[OnMonitor - 1] + WinMovCrctnTop, WinWdt, WinHgt
Return
}
}
}
; HOTKEY
; **************
; Move Active Window to NEXT Monitor
!NumPadRight::
{
If (!GetKeyState("NumLock", "T"))
{
GoSub, RgtHlfSub
Return
}
}
!+]::
!+NumPad6::
!+NumPadRight::
!+RButton::
{
GoSub, ExcludPrgrm
If (IgnorePrgrm == True)
{
Return
}
If (MonQty == 1)
{
GoSub, NextQdr
Return
}
WinGetPos, WinHrz, WinVrt, WinWdt, WinHgt, A
GoSub, WinCurntMon
GoSub, WinCurntQdr
GoSub, CrctnFctr
WinGet, WinMMax, MinMax, A
WinMovCrctnLft := WinHrz - MonLft[OnMonitor]
WinMovCrctnTop := WinVrt - MonTop[OnMonitor]
If ((WinVrt == MonTop[OnMonitor] AND WinHgt == MonHgt[OnMonitor] + HgtCrctn) OR WinMMax == 1)
{
; If Active Window is Located on LAST Monitor, Move Active Window to Monitor #1 (Keep Full Window Height)
If (OnMonitor == MonQty)
{
WinMove, A, , MonLft[1] + WinMovCrctnLft, MonTop[1], WinWdt, MonHgt[1] + HgtCrctn
Return
}
Else
{
WinMove, A, , MonLft[OnMonitor + 1] + WinMovCrctnLft, MonTop[OnMonitor + 1], WinWdt, MonHgt[OnMonitor + 1] + HgtCrctn
Return
}
}
; If Active Window is Located in a Quadrant on Current Monitor, Move and Resize Active Window to same Quadrant on NEXT Monitor, regardless of Work Area
Else If (OnQuadrant == 1 OR OnQuadrant == 2 OR OnQuadrant == 3 OR OnQuadrant == 4)
{
; If Active Window is Located in a Quadrant on LAST Monitor, Move and Resize Active Window to same Quadrant on Monitor #1, regardless of Work Area
If (OnMonitor == MonQty)
{
WinMove, A, , MonQdrLft[1, OnQuadrant] + HrzCrctn, MonQdrTop[1, OnQuadrant], MonQdrWdt[1, OnQuadrant] + WdtCrctn, MonQdrHgt[1, OnQuadrant] + HgtCrctn
Return
}
; Move and Resize Active Window to same Quadrant on NEXT Monitor, regardless of Work Area
Else
{
WinMove, A, , MonQdrLft[OnMonitor + 1, OnQuadrant] + HrzCrctn, MonQdrTop[OnMonitor + 1, OnQuadrant], MonQdrWdt[OnMonitor + 1, OnQuadrant] + WdtCrctn, MonQdrHgt[OnMonitor + 1, OnQuadrant] + HgtCrctn
Return
}
}
Else
{
If (OnMonitor == MonQty)
{
WinMove, A, , MonLft[1] + WinMovCrctnLft, MonTop[1] + WinMovCrctnTop, WinWdt, WinHgt
Return
}
Else
{
WinMove, A, , MonLft[OnMonitor + 1] + WinMovCrctnLft, MonTop[OnMonitor + 1] + WinMovCrctnTop, WinWdt, WinHgt
Return
}
}
}
; HOTKEY
; **************
; Move Active Window to UPPER Monitor
!NumPadUp::
{
If (!GetKeyState("NumLock", "T"))
{
GoSub, MaxWinSub
Return
}
}
!+=::
!+NumPad8::
!+NumPadUp::
!+WheelUp::
{
; If Focus is on an Exluded Program (I.e.Desktop), Ignore this HotKey
GoSub, ExcludPrgrm
If (IgnorePrgrm == True)
{
Return
}
WinGetPos, WinHrz, WinVrt, WinWdt, WinHgt, A
GoSub, WinCurntMon
GoSub, WinCurntQdr
GoSub, WinCurntMtx
GoSub, CrctnFctr
WinGet, WinMMax, MinMax, A
; If there is only 1 Row of Monitors, Ignore this HotKey
If (OnMtxRowQty == 1)
{
Return
}
WinMovCrctnLft := WinHrz - MtxLft[OnMtxRow, OnMtxCol]
WinMovCrctnTop := WinVrt - MtxTop[OnMtxRow, OnMtxCol]
; If Active Window is Full Vertical Height on Current Monitor, keep Full Vertical Height on UPPER Monitor, regardless of difference in Monitor Height
If ((WinVrt == MtxTop[OnMtxRow, OnMtxCol] AND WinHgt == MtxHgt[OnMtxRow, OnMtxCol] + HgtCrctn) OR WinMMax == 1)
{
; If Active Window is Located on TOP Row of Monitors, Move Active Window to BOTTOM Most Row of Monitors (Keep Full Window Height)
If (OnMtxRow == 1)
{
WinMove, A, , MtxLft[OnMtxRowQty, OnMtxCol] + WinMovCrctnLft, MtxTop[OnMtxRowQty, OnMtxCol], WinWdt, MtxHgt[OnMtxRowQty, OnMtxCol] + HgtCrctn
Return
}
; Move Active Window to UPPER Monitor (Keep Full Window Height)
Else
{
WinMove, A, , MtxLft[OnMtxRow - 1, OnMtxCol] + WinMovCrctnLft, MtxTop[OnMtxRow - 1, OnMtxCol], WinWdt, MtxHgt[OnMtxRow - 1, OnMtxCol] + HgtCrctn
Return
}
}
; If Active Window is Located in a Quadrant on Current Monitor, Move and Resize Active Window to same Quadrant on UPPER Monitor, regardless of Work Area
Else If (OnQuadrant == 1 OR OnQuadrant == 2 OR OnQuadrant == 3 OR OnQuadrant == 4)
{
; If Active Window is Located in a Quadrant on LAST Monitor, Move and Resize Active Window to same Quadrant on Monitor #1, regardless of Work Area
If (OnMtxRow == 1)
{
WinMove, A, , MtxQdrLft[OnMtxRowQty, OnMtxCol, OnQuadrant] + HrzCrctn, MtxQdrTop[OnMtxRowQty, OnMtxCol, OnQuadrant], MtxQdrWdt[OnMtxRowQty, OnMtxCol, OnQuadrant] + WdtCrctn, MtxQdrHgt[OnMtxRowQty, OnMtxCol, OnQuadrant] + HgtCrctn
Return
}
; Move and Resize Active Window to same Quadrant on NEXT Monitor, regardless of Work Area
Else
{
WinMove, A, , MtxQdrLft[OnMtxRow - 1, OnMtxCol, OnQuadrant] + HrzCrctn, MtxQdrTop[OnMtxRow - 1, OnMtxCol, OnQuadrant], MtxQdrWdt[OnMtxRow - 1, OnMtxCol, OnQuadrant] + WdtCrctn, MtxQdrHgt[OnMtxRow - 1, OnMtxCol, OnQuadrant] + HgtCrctn
Return
}
}
Else
{
; If Active Window is Located on Top Row of Monitors, Move Active Window to Bottom Most Row of Monitors
If (OnMtxRow == 1)
{
WinMove, A, , MtxLft[OnMtxRowQty, OnMtxCol] + WinMovCrctnLft, MtxTop[OnMtxRowQty, OnMtxCol] + WinMovCrctnTop, WinWdt, WinHgt
Return
}
; Move Active Window to Upper Monitor
Else
{
WinMove, A, , MtxLft[OnMtxRow - 1, OnMtxCol] + WinMovCrctnLft, MtxTop[OnMtxRow - 1, OnMtxCol] + WinMovCrctnTop, WinWdt, WinHgt
Return
}
}
}
; HOTKEY
; **************
; Move Active Window to LOWER Monitor
!NumPadDown::
{
If (!GetKeyState("NumLock", "T"))
{
GoSub, MinWinSub
Return
}
}
!+\::
!+NumPad2::
!+NumPadDown::
!+WheelDown::
MinWinSub:
{
; If Focus is on an Exluded Program (I.e.Desktop), Ignore this HotKey
GoSub, ExcludPrgrm
If (IgnorePrgrm == True)
{
Return
}
WinGetPos, WinHrz, WinVrt, WinWdt, WinHgt, A
GoSub, WinCurntMon
GoSub, WinCurntQdr
GoSub, WinCurntMtx
GoSub, CrctnFctr
WinGet, WinMMax, MinMax, A
; If there is only 1 Row of Monitors, Ignore this HotKey
If (OnMtxRowQty == 1)
{
Return
}
WinMovCrctnLft := WinHrz - MtxLft[OnMtxRow, OnMtxCol]
WinMovCrctnTop := WinVrt - MtxTop[OnMtxRow, OnMtxCol]
If ((WinVrt == MtxTop[OnMtxRow, OnMtxCol] AND WinHgt == MtxHgt[OnMtxRow, OnMtxCol] + HgtCrctn) OR WinMMax == 1)
{
; If Active Window is Located on Bottom Most Row of Monitors, Move Active Window to Top Row of Monitors (Keep Full Window Height)
If (OnMtxRow == OnMtxRowQty)
{
WinMove, A, , MtxLft[1, OnMtxCol] + WinMovCrctnLft, MtxTop[1, OnMtxCol], WinWdt, MtxHgt[1, OnMtxCol] + HgtCrctn
Return
}
Else
{
WinMove, A, , MtxLft[OnMtxRow + 1, OnMtxCol] + WinMovCrctnLft, MtxTop[OnMtxRow + 1, OnMtxCol], WinWdt, MtxHgt[OnMtxRow + 1, OnMtxCol] + HgtCrctn
Return
}
}
; If Active Window is Located in a Quadrant on Current Monitor, Move and Resize Active Window to same Quadrant on UPPER Monitor, regardless of Work Area
Else If (OnQuadrant == 1 OR OnQuadrant == 2 OR OnQuadrant == 3 OR OnQuadrant == 4)
{
; If Active Window is Located in a Quadrant on LAST Monitor, Move and Resize Active Window to same Quadrant on Monitor #1, regardless of Work Area
If (OnMtxRow == OnMtxRowQty)
{
WinMove, A, , MtxQdrLft[1, OnMtxCol, OnQuadrant] + HrzCrctn, MtxQdrTop[1, OnMtxCol, OnQuadrant], MtxQdrWdt[1, OnMtxCol, OnQuadrant] + WdtCrctn, MtxQdrHgt[1, OnMtxCol, OnQuadrant] + HgtCrctn
Return
}
; Move and Resize Active Window to same Quadrant on NEXT Monitor, regardless of Work Area
Else
{
WinMove, A, , MtxQdrLft[OnMtxRow + 1, OnMtxCol, OnQuadrant] + HrzCrctn, MtxQdrTop[OnMtxRow + 1, OnMtxCol, OnQuadrant], MtxQdrWdt[OnMtxRow + 1, OnMtxCol, OnQuadrant] + WdtCrctn, MtxQdrHgt[OnMtxRow + 1, OnMtxCol, OnQuadrant] + HgtCrctn
Return
}
}
Else
{
If (OnMtxRow == OnMtxRowQty)
{
WinMove, A, , MtxLft[1, OnMtxCol] + WinMovCrctnLft, MtxTop[1, OnMtxCol] + WinMovCrctnTop, WinWdt, WinHgt
Return
}
Else
{
WinMove, A, , MtxLft[OnMtxRow + 1, OnMtxCol] + WinMovCrctnLft, MtxTop[OnMtxRow + 1, OnMtxCol] + WinMovCrctnTop, WinWdt, WinHgt
Return
}
}
}
; HOTKEY
; **************
; Move and Resize Active Window to UPPER LEFT Corner (Quadrant 1) of Current Monitor OR to BOTTOM LEFT Corner (Quadrant 2) of Current Monitor
#^!+[::
#^!+LButton::
; SubRoutine Label. To be Retrieved when "Move Active Window to PREVIOUS Monitor" is Activated and there is only 1 Monitor in Monitor Configuration
PrevQdr:
{
GoSub, ExcludPrgrm
If (IgnorePrgrm == True)
{
Return
}
WinGetPos, WinHrz, WinVrt, WinWdt, WinHgt, A
WinGet, WinMMax, MinMax, A
GoSub, WinCurntMon
; Retrieves in which Quadrant Number of Current Monitor the Active Window is on.
GoSub, WinCurntQdr
GoSub, CrctnFctr
If (WinMMax == 1)
{
WinRestore, A
}
; If Active Window is TOP LEFT Corner (Quadrant 1) OR in BOTTOM RIGHT Corner (Quadrant 4) of Current Monitor, Move and Resize Active Window to LOWER LEFT Corner (Quadrant 2) of Current Monitor
If (OnQuadrant == 1 OR OnQuadrant == 4)
{
WinMove, A, , MonQdrLft[OnMonitor, 2] + HrzCrctn, MonQdrTop[OnMonitor, 2], MonQdrWdt[OnMonitor, 2] + WdtCrctn, MonQdrHgt[OnMonitor, 2] + HgtCrctn
Return
}
; Else Move Active Window to TOP LEFT Corner (Quadrant 1) of Current Monitor
Else
{
WinMove, A, , MonQdrLft[OnMonitor, 1] + HrzCrctn, MonQdrTop[OnMonitor, 1], MonQdrWdt[OnMonitor, 1] + WdtCrctn, MonQdrHgt[OnMonitor, 1] + HgtCrctn
Return
}
}
; HOTKEY
; **************
; Move and Resize Active Window to UPPER Right Corner (Quadrant 3) of Current Monitor OR to BOTTOM RIGHT Corner (Quadrant 4) of Current Monitor for other circumstances
#^!+]::
#^!+RButton::
; SubRoutine Label. To be Retrieved when "Move Active Window to NEXT Monitor" is Activated and there is only 1 Monitor in Monitor Configuration
NextQdr:
{
WinGetPos, WinHrz, WinVrt, WinWdt, WinHgt, A
WinGet, WinMMax, MinMax, A
GoSub, WinCurntMon
GoSub, WinCurntQdr
GoSub, CrctnFctr
If (WinMMax == 1)
{
WinRestore, A
}
; If Active Window is in UPPER RIGHT Corner (Quadrant 3) OR in LOWER LEFT Corner (Quadrant 2) of Current Monitor, Move and Resize Active Window to LOWER RIGHT Corner (Quadrant 4) of Current Monitor
If (OnQuadrant == 3 OR OnQuadrant == 2)
{
WinMove, A, , MonQdrLft[OnMonitor, 4] + HrzCrctn, MonQdrTop[OnMonitor, 4], MonQdrWdt[OnMonitor, 4] + WdtCrctn, MonQdrHgt[OnMonitor, 4] + HgtCrctn
Return
}
; Else Move Active Window to UPPER RIGHT Corner (Quadrant 3) of Current Monitor
Else
{
WinMove, A, , MonQdrLft[OnMonitor, 3] + HrzCrctn, MonQdrTop[OnMonitor, 3], MonQdrWdt[OnMonitor, 3] + WdtCrctn, MonQdrHgt[OnMonitor, 3] + HgtCrctn
Return
}
}
; HOTKEY
; **************
; Move and Resize Active Window to UPPER LEFT Corner of Current Monitor (Quadrant 1)
!NumPad7::
#^!+NumPad7::
#^!+NumPadHome::
#^!NumPadHome::
{
WinGetPos, WinHrz, WinVrt, WinWdt, WinHgt, A
GoSub, WinCurntMon
GoSub, WinCurntQdr
GoSub, CrctnFctr
WinGet, WinMMax, MinMax, A
If (WinMMax == 1)
{
WinRestore, A
}
WinMove, A, , MonQdrLft[OnMonitor, 1] + HrzCrctn, MonQdrTop[OnMonitor, 1], MonQdrWdt[OnMonitor, 1] + WdtCrctn, MonQdrHgt[OnMonitor, 1] + HgtCrctn
Return
}
; HOTKEY
; **************
; Move and Resize Active Window to LOWER LEFT Corner of Current Monitor (Quadrant 2)
!NumPad1::
#^!+NumPad1::
#^!+NumPadEnd::
#^!NumPadEnd::
{
WinGetPos, WinHrz, WinVrt, WinWdt, WinHgt, A
GoSub, WinCurntMon
GoSub, WinCurntQdr
GoSub, CrctnFctr
WinGet, WinMMax, MinMax, A
If (WinMMax == 1)
{
WinRestore, A
}
WinMove, A, , MonQdrLft[OnMonitor, 2] + HrzCrctn, MonQdrTop[OnMonitor, 2], MonQdrWdt[OnMonitor, 2] + WdtCrctn, MonQdrHgt[OnMonitor, 2] + HgtCrctn
Return
}
; HOTKEY
; **************
; Move and Resize Active Window to UPPER RIGHT Corner of Current Monitor (Quadrant 3)
!NumPad9::
#^!+NumPad9::
#^!+NumPadPgUp::
#^!NumPadPgUp::
{
WinGetPos, WinHrz, WinVrt, WinWdt, WinHgt, A
GoSub, WinCurntMon
GoSub, WinCurntQdr
GoSub, CrctnFctr
WinGet, WinMMax, MinMax, A
If (WinMMax == 1)
{
WinRestore, A
}
WinMove, A, , MonQdrLft[OnMonitor, 3] + HrzCrctn, MonQdrTop[OnMonitor, 3], MonQdrWdt[OnMonitor, 3] + WdtCrctn, MonQdrHgt[OnMonitor, 3] + HgtCrctn
Return
}
; HOTKEY
; **************
; Move and Resize Active Window to LOWER RIGHT Corner of Current Monitor (Quadrant 4)
!NumPad3::
#^!+NumPad3::
#^!+NumPadPgDn::
#^!NumPadPgDn::
{
WinGetPos, WinHrz, WinVrt, WinWdt, WinHgt, A
GoSub, WinCurntMon
GoSub, WinCurntQdr
GoSub, CrctnFctr
WinGet, WinMMax, MinMax, A
If (WinMMax == 1)
{
WinRestore, A
}
WinMove, A, , MonQdrLft[OnMonitor, 4] + HrzCrctn, MonQdrTop[OnMonitor, 4], MonQdrWdt[OnMonitor, 4] + WdtCrctn, MonQdrHgt[OnMonitor, 4] + HgtCrctn
Return
}
; HOTKEY
; **************
; FOCUS on Window with Mouse Cursor and MINIMIZE Window
!WheelDown::
{
MouseGetPos,,, WinID
WinGetClass, CNameWinMin, ahk_id %WinID%
; If Focus is on Desktop or Taskbar, Ignore this HotKey
If (CNameWinMin == "WorkerW" OR CNameWinMin == "Shell_TrayWnd")
{
Return
}
Else
{
WinMinimize, ahk_id %WinID%
Return
}
}
; HOTKEY
; **************
; MINIMIZE Window (Does not give Focus to Window)
!-::
!NumPad2::
#^!+NumPad2::
#^!+NumPadDown::
#^!NumPadDown::
{
; If Focus is on Desktop or Taskbar, Ignore this HotKey
WinGetClass, CNameWinMin, A
If (CNameWinMin == "WorkerW" OR CNameWinMin == "Shell_TrayWnd")
{
Return
}
Else
{
WinMinimize, A
Return
}
}
; HOTKEY
; **************
;MAXIMIZE Window (Does not give Focus to Window)
!=::
!NumPad8::
#^!+NumPad8::
#^!+NumPadUp::
#^!NumPadUp::
!WheelUp::
MaxWinSub:
{
; If Focus is on Desktop, Ignore this HotKey
WinGetClass, CNameWinMax, A
If (CNameWinMax == "WorkerW")
{
Return
}
Else
{
WinMaximize, A
Return
}
}
; HOTKEY
; **************
; FOCUS on Window with Mouse Cursor and CLOSE Window
!MButton::
{
MouseGetPos,,, WinID
WinGetClass, CNameWinCls, ahk_id %WinID%
; If Focus is on Desktop or Taskbar, Ignore this HotKey
If (CNameWinCls == "WorkerW" OR CNameWinCls == "Shell_TrayWnd")
{
Return
}
Else
{
WinClose, ahk_id %WinID%
Return
}
}
; HOTKEY
; **************
; CLOSE Window (Does not give Focus to Window)
!'::
!NumPad0::
#^!+NumPad0::
#^!+NumPadIns::
#^!NumPadIns::
^+w::
{
; If Focus is on Desktop or Taskbar, Ignore this HotKey
WinGetClass, CNameWinCls, A
If (CNameWinCls == "WorkerW" OR CNameWinCls == "Shell_TrayWnd")
{
Return
}
Else
{
WinClose, A
Return
}
}
; User Defined Values and Programs
; ****************************************
; ***** Gosub Label *****
; Correction Factor to implement for specific Programs
CrctnFctr:
{
WinGet, PNameWin, ProcessName, A
If (PNameWin == "Code.exe" OR PNameWin == "Spotify.exe" OR PNameWin == "OUTLOOK.EXE" OR PNameWin == "lync.exe" OR PNameWin == "slack.exe" OR PNameWin == "WINWORD.EXE" OR PNameWin == "EXCEL.EXE" OR PNameWin == "Revu.exe")
{
HrzCrctn = 0
HgtCrctn = 0
WdtCrctn = 0
Return
}
; For some reason, there is an offset when working with Explorer and Chrome
Else
{
HrzCrctn = -7
HgtCrctn = 7
WdtCrctn = 14
Return
}
}
; User Defined Values and Programs
; ****************************************
; ***** Gosub Label *****
; Exluded Programs, where the HotKeys will NOT WORK
ExcludPrgrm:
{
WinGetClass, CNameHlfLft, A
ExcludPrgrm := False
; WorkerW ➔ Desktop
If (CNameHlfLft == "WorkerW")
{
IgnorePrgrm := True
}
Return
}
; ***** Gosub Label *****
; Retrieves on which Monitor Number the Active Window is on
; Used to Move Window from Right to Left Monitors
WinCurntMon:
{
WinGetPos, WinHrz, WinVrt, WinWdt, WinHgt, A
WinHgtCtr := WinVrt + WinHgt / 2
WinHrzCtr := WinHrz + WinWdt / 2
Loop, %MonQty%
{
; If Center of Active Window is Located between defined Boundaries, Active Window is Located on Monitor #X
If (WinHgtCtr >= MonTop[A_Index] AND WinHgtCtr <= MonBtm[A_Index] AND WinHrzCtr >= MonLft[A_Index] AND WinHrzCtr <= MonRgt[A_Index])
{
OnMonitor := A_Index
; Once Matching Monitor Found, Stop the Search
Break
}
}
Return
}
; ***** Gosub Label *****
; Finds on which Monitor Row and Column (Matrix) the Active Window is on
; Used to Move Window from Upper to Lower Monitors
WinCurntMtx:
{
WinGetPos, WinHrz, WinVrt, WinWdt, WinHgt, A
WinHgtCtr := WinVrt + WinHgt / 2
WinHrzCtr := WinHrz + WinWdt / 2
Loop, %ColQty%
{
ColPosA_Index := A_Index
Col_RowQtyLoop := Col_RowQty[ColPosA_Index]
Loop, %Col_RowQtyLoop%
{
VrtMtxOrdrA_Index := A_Index
; If Center of Active Window is Located between defined Boundaries, Active Window is Located on Row #X and Column #X
If (WinHgtCtr >= MtxTop[VrtMtxOrdrA_Index, ColPosA_Index] AND WinHgtCtr <= MtxBtm[VrtMtxOrdrA_Index, ColPosA_Index] AND WinHrzCtr >= MtxLft[VrtMtxOrdrA_Index, ColPosA_Index] AND WinHrzCtr <= MtxRgt[VrtMtxOrdrA_Index, ColPosA_Index])
{
OnMtxRow := VrtMtxOrdrA_Index
OnMtxCol := ColPosA_Index
OnMtxRowQty := Col_RowQty[ColPosA_Index]
; Once Matching Monitor Found, Stop the Search
Break
}
}
}
Return
}
; ***** Gosub Label *****
; Retrieves in which Quadrant Number of Current Monitor the Active Window is on.
WinCurntQdr:
{
WinGetPos, WinHrz, WinVrt, WinWdt, WinHgt, A
; If it is not on any Quadrant, OnQuadrant = 0
OnQuadrant := 0
Loop, 4
{
; If Active Window is Located on one of the 4 Quadrants, Active Window is Located on Quadrant #X
If (WinHrz == MonQdrLft[OnMonitor, A_Index] + HrzCrctn AND WinVrt == MonQdrTop[OnMonitor, A_Index] AND WinWdt == MonQdrWdt[OnMonitor, A_Index] + WdtCrctn AND WinHgt == MonQdrHgt[OnMonitor, A_Index] + HgtCrctn)
{
OnQuadrant := A_Index
; Once Matching Quadrant is Found, Stop the Search
Break
}
}
Return
}
; *******************************************************************************
; Automatic Mapping of All Monitors, Move & Resize Windows -END-
; *******************************************************************************