Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2018
451
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ; Adjust the variables below. You'll usually want to start with 0 and adjust up bit by bit until all borders/scrollbars/etc are hidden.
  3. ;;;;;;;;;;;;;;;;;;;;;;;;;;
  4.  
  5. global BGColor := "000000" ; The background color (default is black)
  6. global TopSub := 26 ; How many pixels you want to mask from the top of the application window
  7. global BottomSub := 3 ; How many pixels you want to mask from the bottom of the application window
  8. global LeftSub := 0 ; How many pixels you want to mask from the left of the application window
  9. global RightSub := 0 ; How many pixels you want to mask from the right of the application window
  10.  
  11. ;;;;;;;;;;;;;;;;;;;;;;;;;;
  12. ; Code begins below
  13. ;;;;;;;;;;;;;;;;;;;;;;;;;;
  14.  
  15. global WindowID, WinPosX, WinPosY, WindowWidth, WindowHeight
  16. global WindowState := 0
  17. global funcLock := 0
  18. global unloadRequest := 0
  19.  
  20. Loop {
  21.     If WinExist("ahk_id " . WindowID) {
  22.         If WinActive("ahk_id " . WindowID) {
  23.             If (WindowState = 0) {
  24.                 StartMask()
  25.             }
  26.         } Else {
  27.             If (WindowState = 1) {
  28.                 StopMask()
  29.             }
  30.         }
  31.     } Else {
  32.         If (WindowState = 1) {
  33.             StopMask()
  34.         }
  35.     }
  36.     Sleep, 10
  37. }
  38.  
  39. F12::
  40. funcLock := 1
  41. If WinExist("ahk_id " . WindowID) {
  42. } Else {
  43.     WinGet, TempWindowID, ID, A
  44.     WindowID:=TempWindowID
  45. }
  46. If WinExist("ahk_id " . WindowID) {
  47.     If (WindowState = 0) {
  48.         StartMask()
  49.     } Else {
  50.         StopMask()
  51.         ; In this case we're pushing F12 for a second time, so clear the remembered WindowID so it stops auto-applying when the window has focus:
  52.         WindowID:=""
  53.     }
  54. }
  55. funcLock := 0
  56. return
  57.  
  58. StartMask() {
  59.     Gui, Color, %BGColor%
  60.     Gui -Caption -ToolWindow +AlwaysOnTop
  61.     WinGetPos, WinPosX, WinPosY, WindowWidth, WindowHeight, ahk_id %WindowID%
  62.     ; Hide Windows Task Bar and Start Button. (Remove the following two lines if you don't want that behaviour)
  63. ;   WinHide ahk_class Shell_TrayWnd
  64. ;   WinHide Start ahk_class Button
  65.     ; Get the x/y coords of the upper-left position of the window in order to center it on the screen, and then move it there
  66.     WindowXCoord:=((A_ScreenWidth - WindowWidth)/2)
  67.     WindowYCoord:=((A_ScreenHeight - WindowHeight)/2)
  68.     WinMove, ahk_id %WindowID%, , WindowXCoord, WindowYCoord
  69.     ; Build the region string that will define the full monitor area (this is what will be masked by the gui window)
  70.     FullScreenRegion:="0-0 " ; UPPER_LEFT
  71.     FullScreenRegion:=FullScreenRegion . A_ScreenWidth . "-0 " ; UPPER_RIGHT
  72.     FullScreenRegion:=FullScreenRegion . A_ScreenWidth . "-" . A_ScreenHeight . " " ; LOWER_RIGHT
  73.     FullScreenRegion:=FullScreenRegion . "0-" . A_ScreenHeight . " " ; LOWER_LEFT
  74.     FullScreenRegion:=FullScreenRegion . "0-0    " ; UPPER_LEFT (again)
  75.     ; Build the region string that will define the application area (this is the window within the full area that will NOT be masked by the gui window). Take into account the adjustments we defined to take into account window borders/scrollbars/menus/etc
  76.     GameScreenRegion:=WindowXCoord+LeftSub . "-" . WindowYCoord+TopSub . " " ; UPPER_LEFT
  77.     GameScreenRegion:=GameScreenRegion . WindowXCoord+WindowWidth-RightSub . "-" . WindowYCoord+TopSub . " " ; UPPER_RIGHT
  78.     GameScreenRegion:=GameScreenRegion . WindowXCoord+WindowWidth-RightSub . "-" . WindowYCoord+WindowHeight-BottomSub . " " ; LOWER_RIGHT
  79.     GameScreenRegion:=GameScreenRegion . WindowXCoord+LeftSub . "-" . WindowYCoord+WindowHeight-BottomSub . " " ; LOWER_LEFT
  80.     GameScreenRegion:=GameScreenRegion . WindowXCoord+LeftSub . "-" . WindowYCoord+TopSub ; UPPER_LEFT (again)
  81.     ; Show the masking gui (and center it)
  82.     Gui, Show, W1920 H1080, BlackScreen
  83.     WinMove, BlackScreen, , 0, 0
  84.     ; Define the masking regions we set up above, with the transparent region in the middle
  85.     WinSet, Region, % FullScreenRegion . GameScreenRegion, BlackScreen
  86.     ; Now bring the application window to the forefront
  87.     WinActivate, ahk_id %WindowID%
  88.     WindowState:=!WindowState
  89.     return
  90. }
  91.  
  92. StopMask() {
  93.     ; Move the application back to where it originally was:
  94.     WinMove, ahk_id %WindowID%, , WinPosX, WinPosY, WindowWidth, WindowHeight
  95.     ; Show the task bar again
  96. ;   WinShow ahk_class Shell_TrayWnd
  97. ;   WinShow Start ahk_class Button
  98.     ; Remove the masking gui:
  99.     Gui, destroy
  100.     ;WinSet, Region,, ahk_id %WindowID% ; Restore the window to its original/default display area.
  101.     WindowState:=!WindowState
  102.     return
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement