Guest User

Awesome Fake Fullscreen

a guest
Dec 23rd, 2011
758
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Standard Headers
  2. #NoEnv
  3. #Warn
  4. SendMode Input
  5. SetWorkingDir %A_ScriptDir%
  6.  
  7. ; The Hotkey
  8. #f::
  9. ; Get the active window and its style.
  10. WinGet, WindowID, ID, A
  11. WinGet, Style, Style, ahk_id %WindowID%
  12.  
  13. ; If true, blow up the window, otherwise restore it.
  14. If (Style & 0xC40000)
  15. {
  16.     ; Get the window geometry and save it with the window ID for later.
  17.     WinGetPos, PosX_%WindowID%, PosY_%WindowID%, W_%WindowID%, H_%WindowID%, ahk_id %WindowID%
  18.    
  19.     ; Figure out the center.
  20.     xc := PosX_%WindowID% + W_%WindowID%/2
  21.     yc := PosY_%WindowID% + H_%WindowID%/2
  22.    
  23.     ; Now get the monitor the window center is on.
  24.     MID := FindMonitor(xc, yc)
  25.     SysGet, mn, Monitor, %MID%
  26.    
  27.     ; Calculate monitor size.
  28.     mnWidth := mnRight - mnLeft
  29.     mnHeight := mnBottom - mnTop
  30.    
  31.     ; Now, remove the window caption and border, and move the window to fill
  32.     ; the whole monitor.
  33.     WinSet, Style, -0xC40000, ahk_id %WindowID%
  34.     WinMove, ahk_id %WindowID%, , %mnLeft%, %mnTop%, %mnWidth%, %mnHeight%
  35. }
  36. Else
  37. {
  38.     ; First, get back the caption and border.
  39.     WinSet, Style, +0xC40000, ahk_id %WindowID%
  40.    
  41.     ; Now, if we have variables for the window, restore its position, otherwise
  42.     ; fall back to moving it to a visible spot. This should never happen though.
  43.     If (H_%WindowID% <> 0)
  44.     {
  45.         WinMove, ahk_id %WindowID%, , PosX_%WindowID%, PosY_%WindowID%, W_%WindowID%, H_%WindowID%
  46.     }
  47.     Else
  48.     {
  49.         WinMove, ahk_id %WindowID%, , 50, 50, 500, 500
  50.     }
  51. }
  52. return
  53.  
  54. ; Helper Functions
  55. FindMonitor(xc, yc)
  56. {
  57.     SysGet, mc, MonitorCount
  58.     Loop, %mc%
  59.     {
  60.         SysGet, moni, Monitor, %A_Index%
  61.         if (xc >= moniLeft and xc <= moniRight and yc >= moniTop and yc <= moniBottom)
  62.         {
  63.             return %A_Index%
  64.         }
  65.     }
  66.     return 0
  67. }
Advertisement
Add Comment
Please, Sign In to add comment