Last active
January 18, 2018 21:05
-
-
Save lewis-carson/e1f00d4ee0692a500eaac3615b0da976 to your computer and use it in GitHub Desktop.
My custom AHK script. remember to change the paths at the end if you want the shortcuts for sublime, hyper, and chrome. To use install autohotkey and place this script in your startup folder. **disclaimer: i didnt make most of this script. It is just hacked togetehr from throughout the web**
This file contains 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
#Persistent | |
#SingleInstance force | |
;; tiling window manager for windows 7-10 designed for 1 or 2 monitors arranging | |
;; windows in the following pattern with configurable window sizes and borders: | |
;; _________ _________ | |
;; | | | | |___| <- primary monitor | |
;; | | | | | | | |
;; '---i-----' '-----i---' | |
;; todo override windows move keys, eg, win + left | |
;; -- window sizing options | |
;; size of space between windows | |
windowBorder = 40 | |
;; width of the large windows that appear closest to the center of the screen | |
windowLeftWidth = 1200 | |
;; height of the small top right window | |
windowRightSmallTopHeight = 550 | |
;; monitor geometry | |
;; todo: automate this | |
monitorBorderRight = 1920 | |
monitorBorderLeft = 0 | |
monitorWidth = 1920 | |
monitorHeight = 1080 | |
taskbarHeight = 0 | |
;; override system, here you can define a default offset and specific program offsets | |
;; this will allow you to setup for custom themes and programs that wont behave | |
;; I tried to make this work with WinGetPosEx but even that had many faults | |
global windowOverrides := Object() | |
windowOverrides["default"] := Object() | |
windowOverrides["default"]["left"] := -8 | |
windowOverrides["default"]["top"] := 0 | |
windowOverrides["default"]["width"] := +16 | |
windowOverrides["default"]["height"] := +8 | |
windowOverrides["explorer.exe"] := Object() | |
windowOverrides["explorer.exe"]["left"] := -8 | |
windowOverrides["explorer.exe"]["top"] := 0 | |
windowOverrides["explorer.exe"]["width"] := +16 | |
windowOverrides["explorer.exe"]["height"] := +8 | |
windowOverrides["chrome.exe"] := Object() | |
windowOverrides["chrome.exe"]["left"] := -8 | |
windowOverrides["chrome.exe"]["top"] := 0 | |
windowOverrides["chrome.exe"]["width"] := +16 | |
windowOverrides["chrome.exe"]["height"] := +8 | |
windowOverrides["firefox.exe"] := Object() | |
windowOverrides["firefox.exe"]["left"] := -6 | |
windowOverrides["firefox.exe"]["top"] := 0 | |
windowOverrides["firefox.exe"]["width"] := +12 | |
windowOverrides["firefox.exe"]["height"] := +6 | |
windowOverrides["putty.exe"] := Object() | |
windowOverrides["putty.exe"]["left"] := -4 | |
windowOverrides["putty.exe"]["top"] := 0 | |
windowOverrides["putty.exe"]["width"] := +8 | |
windowOverrides["putty.exe"]["height"] := +4 | |
windowOverrides["WinSCP.exe"] := Object() | |
windowOverrides["WinSCP.exe"]["left"] := -8 | |
windowOverrides["WinSCP.exe"]["top"] := 0 | |
windowOverrides["WinSCP.exe"]["width"] := +16 | |
windowOverrides["WinSCP.exe"]["height"] := +8 | |
windowOverrides["pidgin.exe"] := Object() | |
windowOverrides["pidgin.exe"]["left"] := -8 | |
windowOverrides["pidgin.exe"]["top"] := 0 | |
windowOverrides["pidgin.exe"]["width"] := +16 | |
windowOverrides["pidgin.exe"]["height"] := +8 | |
windowOverrides["ApplicationFrameHost.exe"] := Object() | |
windowOverrides["ApplicationFrameHost.exe"]["left"] := -8 | |
windowOverrides["ApplicationFrameHost.exe"]["top"] := 0 | |
windowOverrides["ApplicationFrameHost.exe"]["width"] := +16 | |
windowOverrides["ApplicationFrameHost.exe"]["height"] := +8 | |
SysGet, MonitorCount, MonitorCount | |
SysGet, MonitorPrimary, MonitorPrimary | |
;;MsgBox, Monitor Count:`t%MonitorCount%`nPrimary Monitor:`t%MonitorPrimary% | |
Loop, %MonitorCount% | |
{ | |
SysGet, MonitorName, MonitorName, %A_Index% | |
SysGet, Monitor, Monitor, %A_Index% | |
SysGet, MonitorWorkArea, MonitorWorkArea, %A_Index% | |
;;MsgBox, Monitor:`t#%A_Index%`nName:`t%MonitorName%`nLeft:`t%MonitorLeft% (%MonitorWorkAreaLeft% work)`nTop:`t%MonitorTop% (%MonitorWorkAreaTop% work)`nRight:`t%MonitorRight% (%MonitorWorkAreaRight% work)`nBottom:`t%MonitorBottom% (%MonitorWorkAreaBottom% work) | |
} | |
;; what happens when: | |
;; -- TaskbarMontior1 Montitor2 | |
;; -- TaskbarMonitor2 Monitor1 | |
;; -- Monitor1 TaskbarMonitor2 | |
;; -- Monitor2 TaskbarMontior1 | |
;; * Monitor2: -1920 | |
;; * Monitor1: 0 | |
;;calculated variables used below | |
windowHeightTall := monitorHeight - (windowBorder * 2) | |
windowHeightTallTaskbar := monitorHeight - (windowBorder * 2) - taskbarHeight | |
windowRightWidth := monitorWidth - windowLeftWidth - (windowBorder * 3) | |
windowWidthFull := monitorWidth - (windowBorder * 2) | |
;; _________ _________ | |
;; | | | | |___| -- LeftLeft | |
;; | X | | | | | | |
;; '---i-----' '-----i---' | |
LeftLeftWidth := windowRightWidth | |
LeftLeftHeight := windowHeightTall | |
LeftLeftLeft := monitorBorderLeft + windowBorder - monitorWidth | |
LeftLeftTop := windowBorder | |
;; _________ _________ | |
;; | | | | |___| -- LeftRight | |
;; | | X | | | | | |
;; '---i-----' '-----i---' | |
LeftRightWidth := windowLeftWidth | |
LeftRightHeight := windowHeightTall | |
LeftRightLeft := windowRightWidth + (windowBorder * 2) - monitorWidth | |
LeftRightTop := windowBorder | |
;; _________ _________ | |
;; | | | | |___| -- RightLeft | |
;; | | | | X | | | |
;; '---i-----' '-----i---' | |
RightLeftWidth := windowLeftWidth | |
RightLeftHeight := windowHeightTallTaskbar | |
RightLeftLeft := windowBorder | |
RightLeftTop := windowBorder | |
;; _________ _________ | |
;; | | | | | | -- RightRight | |
;; | | | | | X | | |
;; '---i-----' '-----i---' | |
RightRightWidth := windowRightWidth | |
RightRightHeight := windowHeightTallTaskbar | |
RightRightLeft := windowLeftWidth + (windowBorder * 2) | |
RightRightTop := windowBorder | |
;; _________ _________ | |
;; | | | | |_X_| -- RightRightTop | |
;; | | | | | | | |
;; '---i-----' '-----i---' | |
RightRightTopWidth := windowRightWidth | |
RightRightTopHeight := windowRightSmallTopHeight | |
RightRightTopLeft := windowLeftWidth + (windowBorder * 2) | |
RightRightTopTop := windowBorder | |
;; _________ _________ | |
;; | | | | |___| -- RightRightTop | |
;; | | | | | X | | |
;; '---i-----' '-----i---' | |
RightRightBotWidth := windowRightWidth | |
RightRightBotHeight := monitorHeight - taskbarHeight - (windowBorder * 3) - windowRightSmallTopHeight | |
RightRightBotLeft := windowLeftWidth + (windowBorder * 2) | |
RightRightBotTop := windowRightSmallTopHeight + (windowBorder * 2) | |
;; simplified winmove function call | |
ResizeWinMine(Width = 0,Height = 0, MyLeft = 0, MyTop = 0) | |
{ | |
WinGetPos,X,Y,W,H,A | |
If %Width% = 0 | |
Width := W | |
If %Height% = 0 | |
Height := H | |
tmpArray := windowOverrides | |
;;PrintArray(tmpArray) | |
noOverrides = 1 | |
For index, value in tmpArray{ | |
;;MsgBox, index:`t%index%`n | |
if(WinActive("ahk_exe" . index)){ | |
MyLeft := MyLeft + windowOverrides[index]["left"] | |
MyTop := MyTop + windowOverrides[index]["top"] | |
Width := Width + windowOverrides[index]["width"] | |
Height := Height + windowOverrides[index]["height"] | |
noOverrides = 0 | |
;;MsgBox, MyLeft:`t%MyLeft%`n | MyTop:`t%MyTop% | Width:`t%Width% | Height:`t%Height% | |
} | |
} | |
if(noOverrides == 1) { | |
MyLeft := MyLeft + windowOverrides["default"]["left"] | |
MyTop := MyTop + windowOverrides["default"]["top"] | |
Width := Width + windowOverrides["default"]["width"] | |
Height := Height + windowOverrides["default"]["height"] | |
;;MsgBox, test2 | |
} | |
WinMove,A,,%MyLeft%,%MyTop%,%Width%,%Height% | |
} | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
Numpad0::ResizeWinMine(RightLeftWidth,RightLeftHeight, RightLeftLeft, RightLeftTop) | |
NumpadDot::ResizeWinMine(RightRightWidth,RightRightHeight, RightRightLeft, RightRightTop) | |
NumpadAdd:: | |
ResizeWinMine(RightLeftWidth,RightLeftHeight, RightLeftLeft, RightLeftTop) | |
ResizeWinMine(windowWidthFull, windowHeightTall, RightRightRight, RightRightTop) | |
Return | |
#1::ResizeWinMine(RightRightTopWidth,RightRightTopHeight, RightRightTopLeft, RightRightTopTop) | |
#2::ResizeWinMine(RightRightBotWidth,RightRightBotHeight, RightRightBotLeft, RightRightBotTop) | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; menu items | |
;; for the menu we have to activate the previos window (may not be perfect in all case) | |
;; because the tray popup itself counts as a window | |
Exit: | |
ExitApp | |
LeftLeft: | |
Send !{Esc} ; Activate previous window | |
ResizeWinMine(LeftLeftWidth,LeftLeftHeight, LeftLeftLeft, LeftLeftTop) | |
return | |
LeftRight: | |
Send !{Esc} ; Activate previous window | |
ResizeWinMine(LeftRightWidth,LeftRightHeight, LeftRightLeft, LeftRightTop) | |
return | |
LeftLarge: | |
Send !{Esc} ; Activate previous window | |
ResizeWinMine(RightLeftWidth,RightLeftHeight, RightLeftLeft, RightLeftTop) | |
return | |
RightSmall: | |
Send !{Esc} ; Activate previous window | |
ResizeWinMine(RightRightWidth,RightRightHeight, RightRightLeft, RightRightTop) | |
return | |
RightSmallTop: | |
Send !{Esc} ; Activate previous window | |
ResizeWinMine(RightRightTopWidth,RightRightTopHeight, RightRightTopLeft, RightRightTopTop) | |
return | |
RightSmallBottom: | |
Send !{Esc} ; Activate previous window | |
ResizeWinMine(RightRightBotWidth,RightRightBotHeight, RightRightBotLeft, RightRightBotTop) | |
return | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; ENTERING MY SCRIPT | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
#Z:: | |
ControlGet, HWND, Hwnd,, SysListView321, ahk_class Progman | |
If HWND = | |
ControlGet, HWND, Hwnd,, SysListView321, ahk_class WorkerW | |
If DllCall("IsWindowVisible", UInt, HWND) | |
WinHide, ahk_id %HWND% | |
Else | |
WinShow, ahk_id %HWND% | |
Return | |
^SPACE:: Winset, Alwaysontop, , A | |
; changing window transparencies | |
#WheelUp:: ; Increments transparency up by 3.375% (with wrap-around) | |
DetectHiddenWindows, on | |
WinGet, curtrans, Transparent, A | |
if ! curtrans | |
curtrans = 255 | |
newtrans := curtrans + 8 | |
if newtrans > 0 | |
{ | |
WinSet, Transparent, %newtrans%, A | |
} | |
else | |
{ | |
WinSet, Transparent, OFF, A | |
WinSet, Transparent, 255, A | |
} | |
return | |
#WheelDown:: ; Increments transparency down by 3.375% (with wrap-around) | |
DetectHiddenWindows, on | |
WinGet, curtrans, Transparent, A | |
if ! curtrans | |
curtrans = 255 | |
newtrans := curtrans - 8 | |
if newtrans > 0 | |
{ | |
WinSet, Transparent, %newtrans%, A | |
} | |
;else | |
;{ | |
; WinSet, Transparent, 255, A | |
; WinSet, Transparent, OFF, A | |
;} | |
return | |
#o:: ; Reset Transparency Settings | |
WinSet, Transparent, 255, A | |
WinSet, Transparent, OFF, A | |
return | |
#y:: ; Press Win+G to show the current settings of the window under the mouse. | |
MouseGetPos,,, MouseWin | |
WinGet, Transparent, Transparent, ahk_id %MouseWin% | |
ToolTip Translucency:`t%Transparent%`n | |
Sleep 2000 | |
ToolTip | |
return | |
XButton1::q | |
XButton2::Shift | |
Numpad2::Run C:\Users\Lewis\AppData\Local\hyper\hyper.exe | |
Numpad3::Run C:\Users\Lewis\AppData\Local\Google\Chrome\Application\chrome.exe | |
NumpadSub::WinSet, Style, ^0x00800000L, A |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment