-- Allows you to make any application full screen by putting a border around it.
-- This is the final polished version: built-in help dialogues, cool animations, and graphical ways to customize everything. Ie, It's pretty user friendly. Give it a shot!
version 8:
#SingleInstance force #NoEnv CoordMode, ToolTip, Screen CoordMode, Pixel, Screen CoordMode, Mouse, screen ;version 8 Gui 2: Add, Text, section,Top: Gui 2: Add, Text, ,Bottom: Gui 2: Add, Text, ,Left: Gui 2: Add, Text, ,Right: Gui 2: Add, Edit, ys number,000 Gui 2: Add, UpDown, VTUpDown Range0-999, 0 Gui 2: Add, Edit, number,000 Gui 2: Add, UpDown, vBUpDown Range0-999, 0 Gui 2: Add, Edit, number,000 Gui 2: Add, UpDown, vLUpDown Range0-999, 0 Gui 2: Add, Edit, number,000 Gui 2: Add, UpDown, vRUpDown Range0-999, 0 Gui 2: Add, Text, xs, Trigger phrase: Gui 2: Add, Edit, xs vTrigPhrase -WantReturn, Trigger Phrase Gui 2: Add, Button, gEditFile xs, Edit file ... Gui 2: Add, Button, Default gSaveToFile xs section , Save Gui 2: Add, Button, gCancel ys, Cancel Gui 2: +AlwaysOnTop Menu, Tray, NoStandard Menu, Tray, add, Define New Border..., MenuNewBorder Menu, Tray, add, Ignore Window..., EditToolWindowList Hotkey, Enter, Off Hotkey, Esc, Off Menu, Tray, add Menu, Tray, add, Show Help, MenuHelp HelpMode := false Menu, Tray, add, Pause, GuiPause Paused := false Menu, Tray, add, Reload, MenuReload Menu, Tray, add, Exit, MenuExit Set4Vars(T,0,B,0,L,0,R,0) Set4Vars(T2,0,B2,0,L2,0,R2,0) Set4Vars(Bord_T,0,Bord_B,0,Bord_L,0,Bord_R,0) GuiColor = 0x000000 Gui 1: Color, %GuiColor% Gui 1: +LastFound +AlwaysOnTop +ToolWindow -Caption Gui 1: show, % "W" . A_ScreenWidth . " H" . A_ScreenHeight . " X0 Y0", GUIWIND WinGet, GUI_ID, ID, GUIWIND GoSub, LoadSettingsFromFile BorderHidden := false PrevWinID := 00000 Loop { If HelpMode ShowMainHelpMessage() PaintBorder() If (BorderHidden) { WaitMouseIdleOrNewActiveWindow(1200) PaintBorder() BorderHidden := false } WinWaitNotActive, ahk_id %PrevWinID% If (PrevWinID = GUI_ID) WaitMouseIdle(2000) If (WinExist("A") != GUI_ID) Sleep 500 } Return WaitMouseIdle(time) { MouseGetPos, MouseX, MouseY Loop { Sleep, %time% MouseGetPos, MouseX2, MouseY2 if (MouseX2 != MouseX or MouseY2 != MouseY) { MouseX := MouseX2 MouseY := MouseY2 } else break } } WaitMouseIdleOrNewActiveWindow(time) { global PrevWinID MouseGetPos, MouseX, MouseY Loop { Sleep, %time% MouseGetPos, MouseX2, MouseY2 NewWinID := WinExist("A") WinGetClass, WinClass, ahk_id %NewWinID% if InStr(IgnoreClassList, WinClass) Continue else if (NewWinID != PrevWinID) Break else if (MouseX2 != MouseX or MouseY2 != MouseY) { MouseX := MouseX2 MouseY := MouseY2 } else break } } PaintBorder() { global WinGet, NewWinID, ID, A WinGetClass, WinClass, ahk_id %NewWinID% if InStr(IgnoreClassList, WinClass) Return if (NewWinID = GUI_ID) { WinGetPos, CurLeft, CurTop, CurWinW, CurWinH, ahk_id %PrevWinID% WinGet, Minimized, MinMax, ahk_id %PrevWinID% if (Minimized = -1 or PrevWinID = GUI_ID) { PrevWinID := GUI_ID HideBorder() } else if (NewWinW != CurWinW or NewWinH != CurWinH or NewLeft != CurLeft or NewTop != CurTop) { WinActivate, ahk_id %PrevWinID% WinWaitActive, ahk_id %PrevWinID%,,1 Set4Vars(LEFT, CurLeft, TOP, CurTop, BOT, A_ScreenHeight-CurTop-CurWinH, RIGHT, A_ScreenWidth-CurLeft-CurWinW) Set4Vars(T2,TOP+Bord_T,B2,BOT+Bord_B,L2,LEFT+Bord_L,R2,RIGHT+Bord_R) Set4Vars(NewLeft, CurLeft, NewTop, CurTop, NewWinW, CurWinW, NewWinH, CurWInH) AnimateWindowRegion() } else { MouseGetPos, mX, mY if (mX > LEFT and mX < A_ScreenWidth-RIGHT and mY > TOP and mY < A_ScreenHeight-BOT) { WinActivate, ahk_id %PrevWinID% WinWaitActive, ahk_id %PrevWinID%,,1 Set4Vars(T2,TOP,B2,BOT,L2,LEFT,R2,RIGHT) BorderHidden := true AnimateWindowRegion("none") } else { PrevWinID := GUI_ID HideBorder() } } } else { WinGetActiveStats, NewWinTitle, NewWinW, NewWinH, NewLeft, NewTop PrevWinID := NewWinID newcolor = none MatchFound := false Set4Vars(T2,0,B2,0,L2,0,R2,0) i := NumBorders While (i >= 1) { if (Border_%i%_5 and ((SubStr(Border_%i%_5,1,6) = "CLASS_" and InStr(WinClass, SubStr(Border_%i%_5,7))) or InStr(NewWinTitle, Border_%i%_5))) { Set4Vars(LEFT, NewLeft, TOP, NewTop, BOT, A_ScreenHeight-NewTop-NewWinH, RIGHT, A_ScreenWidth-NewLeft-NewWinW) Set4Vars(Bord_T, Border_%i%_1, Bord_B,Border_%i%_2, Bord_L, Border_%i%_3, Bord_R, Border_%i%_4) Set4Vars(T2,TOP+Bord_T,B2,BOT+Bord_B,L2,LEFT+Bord_L,R2,RIGHT+Bord_R) newcolor := Border_%i%_6 MatchFound := true Break } i-- } If (BorderAlwaysOn and not MatchFound) { Set4Vars(LEFT, NewLeft, TOP, NewTop, BOT, A_ScreenHeight-NewTop-NewWinH, RIGHT, A_ScreenWidth-NewLeft-NewWinW) Set4Vars(Bord_T, Border_%DefaultBorderNumber%_1, Bord_B,Border_%DefaultBorderNumber%_2, Bord_L, Border_%DefaultBorderNumber%_3, Bord_R, Border_%DefaultBorderNumber%_4) Set4Vars(T2,TOP+Bord_T,B2,BOT+Bord_B,L2,LEFT+Bord_L,R2,RIGHT+Bord_R) newcolor := Border_%DefaultBorderNumber%_6 } AnimateWindowRegion(newcolor) } } Set4Vars(ByRef X1, V1, ByRef X2 = "", V2 = "", ByRef X3 = "", V3 = "", ByRef X4 = "", V4 = "") { X1 := V1 X2 := V2 X3 := V3 X4 := V4 } AnimateWindowRegion(Color = "") { global T2 := (T2 < 0 or T2 > A_ScreenHeight) ? 0 : T2 B2 := (B2 < 0 or B2 > A_ScreenHeight) ? 0 : B2 L2 := (L2 < 0 or L2 > A_ScreenWidth) ? 0 : L2 R2 := (R2 < 0 or R2 > A_ScreenWidth) ? 0 : R2 Loop, 15 { v := 16-A_Index Set4Vars(L,L+(L2-L)/v,R,R+(R2-R)/v,T,T+(T2-T)/v,B,B+(B2-B)/v) WinSet, Region, % "0-0 " . A_ScreenWidth . "-0 " . A_ScreenWidth . "-" . A_ScreenHeight . " 0-" . A_ScreenHeight . " 0-0 " . L . "-" . T+3 . " " . L+3 . "-" . T . " " . A_ScreenWidth-R-3 . "-" . T . " " . A_ScreenWidth-R . "-" . T+3 . " " . A_ScreenWidth-R . "-" . A_ScreenHeight-B-3 . " " . A_ScreenWidth-R-3 . "-" . A_ScreenHeight-B . " " . L+3 . "-" . A_ScreenHeight-B . " " . L . "-" . A_ScreenHeight-B-3 . " " . L . "-" . T+3, GUIWIND Sleep, 20 } Sleep, 200 if (Color != "none" and Color != GuiColor) { If Color = PixelGetColor, Color, L2, T2+4 SetFormat, integer, hex Set4Vars(GUR,Color >> 16,GUG,mod(Color, 0x10000) >> 8,GUB,mod(Color, 0x100)) Set4Vars(PXR,GuiColor >> 16,PXG,mod(GuiColor, 0x10000) >> 8,PXB,mod(GuiColor, 0x100)) Loop, 15 { v := 16-A_Index Set4Vars(PXR,PXR+(GUR-PXR)//v,PXG,PXG+(GUG-PXG)//v,PXB,PXB+(GUB-PXB)//v) GuiColor := (PXB << 16) + (PXG << 8) + PXR Gui 1: Color, %GuiColor% Sleep, 20 } SetFormat, integer, d } } GuiContextMenu: Menu, Tray, show return GuiPause: Paused := not Paused Menu, Tray, ToggleCheck, Pause If Paused HideBorder() While Paused WinWaitActive, ahk_id %GUI_ID% Return MenuExit: ExitApp MenuNewBorder: HideBorder() WinActivate, ahk_id %GUI_ID% MsgBox, Activate the window on which you wish to define the new border. WinWaitNotActive, ahk_id %GUI_ID% WinID := WinExist("A") WinGetClass, WindowClassName, ahk_id %WinID% WinGetPos, Left0, Top0, WinW0, WinH0, ahk_id %WinID% GuiControl,2:,TrigPhrase,CLASS_%WindowClassName% Gui 2: Show,,MakeCustomBorder Saved := false Set4Vars(LEFT, Left0, TOP, Top0, BOT, A_ScreenHeight-Top0-WinH0, RIGHT, A_ScreenWidth-Left0-WinW0) Set4Vars(T, TOP, B, BOT, L, LEFT, R, RIGHT) WinSet, Region, % "0-0 " . A_ScreenWidth . "-0 " . A_ScreenWidth . "-" . A_ScreenHeight . " 0-" . A_ScreenHeight . " 0-0 " . L . "-" . T+3 . " " . L+3 . "-" . T . " " . A_ScreenWidth-R-3 . "-" . T . " " . A_ScreenWidth-R . "-" . T+3 . " " . A_ScreenWidth-R . "-" . A_ScreenHeight-B-3 . " " . A_ScreenWidth-R-3 . "-" . A_ScreenHeight-B . " " . L+3 . "-" . A_ScreenHeight-B . " " . L . "-" . A_ScreenHeight-B-3 . " " . L . "-" . T+3, GUIWIND If HelpMode ToolTip, ( - Adjust the borders with the arrows. Alternatively, you can click on the edit box and mouse scroll. - The default trigger phrase is the current window class. If "CLASS_" is ommitted, the window title is used instead. - Manually edit the borders by using "Edit file...". You can do this only after defining your first border. ), 20,20 While (WinExist("MakeCustomBorder")) { Sleep, 200 Gui 2: Submit, NoHide Set4Vars(T,TOP+TUpDown,B,BOT+BUpDown,L,LEFT+LUpDown,R,RIGHT+RUpDown) WinSet, Region, % "0-0 " . A_ScreenWidth . "-0 " . A_ScreenWidth . "-" . A_ScreenHeight . " 0-" . A_ScreenHeight . " 0-0 " . L . "-" . T+3 . " " . L+3 . "-" . T . " " . A_ScreenWidth-R-3 . "-" . T . " " . A_ScreenWidth-R . "-" . T+3 . " " . A_ScreenWidth-R . "-" . A_ScreenHeight-B-3 . " " . A_ScreenWidth-R-3 . "-" . A_ScreenHeight-B . " " . L+3 . "-" . A_ScreenHeight-B . " " . L . "-" . A_ScreenHeight-B-3 . " " . L . "-" . T+3, GUIWIND } If (Saved) { FileAppend,`n%TUpDown%¢%BUpDown%¢%LUpDown%¢%RUpDown%¢%TrigPhrase%,CustomBorders.txt GoSub, LoadSettingsFromFile } HideBorder() If HelpMode ShowMainHelpMessage() Return EditFile: IfExist, CustomBorders.txt { HideBorder() Gui 2: Hide Run, CustomBorders.txt Sleep, 1000 ToolTip MsgBox, ( Examples: - A 10 pixel top, 15 pixel bottom, 13 pixel left, 32 pixel right border triggered by window titles containing "Microsoft": 10¢15¢13¢32¢Microsoft - An always purple border: 10¢15¢13¢32¢Microsoft¢FF00FF - "ALL_WINDOWS" matches all unignored windows: 0¢0¢0¢0¢ALL_WINDOWS - "CLASS_" matches window classes rather than titles. 10¢15¢13¢32¢CLASS_Microsoft Word - For multiple matches, the LAST (most recently added) is used. ) } else MsgBox, You can only edit Customborders.txt after saving at least one border. Return 2GuiClose: Cancel: Gui, Submit Return SaveToFile: Saved := true Gui, Submit Return EditToolWindowList: HideBorder() If HelpMode ToolTip, ( - You may wish to ignore tool windows or dialogue boxes that activate or deactivate the border. - This list is stored in IgnoredWindowClasses.txt - Currently, the ignored window classes are: %IgnoreClassList% ),20,20 Hotkey, Enter, On Hotkey, Esc, On SearchingForWindow := true While (SearchingForWindow) { WinGetClass, ToolWinClass, A ToolTip, Current window class is: "%ToolWinClass%"`nPress ENTER to confirm or ESCAPE to cancel,,,2 Sleep 300 } Hotkey, Enter, Off Hotkey, Esc, Off ToolTip,,,,2 If HelpMode ShowMainHelpMessage() Return Enter:: ToolTip,,,,2 MsgBox,4,, Append %ToolWinClass% to tool window list? (This window will not trigger the border from now on). IfMsgBox Yes { FileAppend,`n%ToolWinClass%,IgnoredWindowClasses.txt MsgBox %ToolWinClass% has been added to the list. GoSub, LoadSettingsFromFile } SearchingForWindow := false Return Esc:: ToolTip,,,,2 SearchingForWindow := false Return MenuHelp: HelpMode := not HelpMode Menu, tray, togglecheck, Show Help If not HelpMode ToolTip else ShowMainHelpMessage() Return MenuReload: Reload Return ShowMainHelpMessage() { ToolTip, ( Welcome to Universal Dark Room: Make any application full screen! GETTING STARTED: - First, define a border by right-clicking on one of the four corners of the screen and selecting "Define New Border..." ABOUT THE BORDER: - The border will activate on a few seconds of mouse idle. - Deactivate by clicking on it or by switching windows. - You can deactivate the small part of the border that covers over the window by clicking on that part. This is helpful for temporarily showing menus. - The border color matches pixel (0,4), which is the pixel just below the top left triangular corner. ),20,20 } LoadSettingsFromFile: IfNotExist CustomBorders.txt Gosub, MenuHelp else FileRead, MenuString, CustomBorders.txt IfNotExist, IgnoredWindowClasses.txt FileAppend, Shell_TrayWnd`n#32770`nChrome_WidgetWin_1`nNet UI Tool Window, IgnoredWindowClasses.txt else FileRead, IgnoreClassList, IgnoredWindowClasses.txt NumBorders := 0 Loop, parse, MenuString, `n,`r { NumBorders := A_Index Loop, Parse, A_LoopField, ¢ Border_%NumBorders%_%A_Index% := A_LoopField if (Border_%NumBorders%_5 = "ALL_WINDOWS") { BorderAlwaysOn := true DefaultBorderNumber := NumBorders } } Return HideBorder() { global Set4Vars(T2,0,B2,0,L2,0,R2,0) AnimateWindowRegion("none") }