AutoHotkey Community

It is currently May 27th, 2012, 2:04 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 23 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: You
PostPosted: February 1st, 2010, 4:51 am 
You just got on lifehacker... O.o
http://lifehacker.com/5458809/universal-darkroom-turns-any-application-into-a-distraction+free-zone


Report this post
Top
  
Reply with quote  
 Post subject: Oh, and
PostPosted: February 1st, 2010, 5:00 am 
If you move the window in question while it is being distraction-freed, it leaves a hole.


Report this post
Top
  
Reply with quote  
 Post subject: doesn't work in win 7?
PostPosted: October 21st, 2010, 7:19 pm 
It doesn't seem to work on my win7. The screen flashes black then normal again, except for the introductory text.

Any ideas?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 12th, 2010, 6:08 am 
Offline

Joined: November 12th, 2010, 6:05 am
Posts: 1
I updated the script to hide the taskbar as well. Not sure if I did it right since I'm new at ahk scripting but seems to work fine!

Code:
#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
   }
   if (Color != "none" and Color != GuiColor) {
     WinHide ahk_class Shell_TrayWnd
      WinHide,Start ahk_class Button
   } else {
      WinShow ahk_class Shell_TrayWnd
      WinShow,Start ahk_class Button
   }
   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")
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 30th, 2010, 10:11 am 
Offline

Joined: December 21st, 2007, 9:33 am
Posts: 10
This script would be awesome if there were an option to only activate it when the window is maximized. I use it to get rid of titlebars. I'm on a small laptop, so when the window is _not_ maximized, this means I need to have multiple windows visible, so the script gets in the way...

Also, is there a way to make the border instant instead of animated?.. Animations are more of a distraction...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 3rd, 2011, 2:21 am 
Offline

Joined: December 8th, 2006, 3:56 pm
Posts: 6
zxzxlch wrote:
I updated the script to hide the taskbar as well. Not sure if I did it right since I'm new at ahk scripting but seems to work fine!

Code:
#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
   }
   if (Color != "none" and Color != GuiColor) {
     WinHide ahk_class Shell_TrayWnd
      WinHide,Start ahk_class Button
   } else {
      WinShow ahk_class Shell_TrayWnd
      WinShow,Start ahk_class Button
   }
   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")
}


Sorry to resurrect an old topic, but I really enjoy this script. Is there any way to make it work with dual monitors? Basically, to get it to function properly, I have to turn the second monitor off.

Maybe it doesn't even have to work with dual monitors, just fill the second screen with the background color...

Thanks for the help!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 6th, 2011, 8:40 pm 
Is this similar to Firefox "Full Screen"?


Report this post
Top
  
Reply with quote  
PostPosted: November 4th, 2011, 5:20 am 
Offline

Joined: November 4th, 2011, 5:15 am
Posts: 1
Hi, thanks muchly for this great script.
Thanks to this I use it to mask out window UI elements and am able to program powerpoint-style pseudo-fullscreen presentations using MATLAB (with realtime 3D interactivity :)

But one question, which part of the code brings up the windows taskbar upon mouse activity?
I am currently getting around this by completely hiding it using Taskbar Eliminator.
However a native option would be handy.

Cheers,
Mike


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 23 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], notsoobvious, Relayer and 11 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group