Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Borderless windowed mode / forced fullscreen script (toggle)


  • Please log in to reply
4 replies to this topic
Klaus2
  • Members
  • 7 posts
  • Last active: Dec 01 2018 02:59 PM
  • Joined: 01 Sep 2012

I have assembled a script for forcing programs into borderless fullscreen mode and thought I'd share it. 

 

1. Purpose / Intended function

 

The script is intended to simulate borderless windowed mode / fullscreen by

  • Hiding window decorations 
  • Making the program span the whole screen
  • Making the program sit in front of the taskbar. 

It should work in theory for both games and desktop programs, across multiple monitors (the program should fill the monitor it's center currently resides on) and should correctly restore position, size and decorations of windows by storing their state in an associative array.

 

It can also be used as an approximation of the "distraction free editing" concept, as it reduces screen clutter.

 

For games:

  • Start the game in windowed mode.
  • Make the game resolution and the screen resolution match (not needed for games like minecraft that support arbitrary windows sizes). 
  • Press your ToggleFakeFullscreen hotkey. (Default: F12). 

 

2. Limitations

  • If the program has modified the decorations (e.g. by putting control elements into the title bar as seen in Microsofts Ribbon UI or Chrome, which replaces the title bar by the tab bar) the results will look bad. 
  • Some programs (observed for Emacs) will sit behind the taskbar. An additional "hide taskbar" script or enabling "autohide taskbar" will be needed when using this script with such programs. 
  • Doesn't work for programs that don't support normal resizing, such as cmd.exe
  • Some programs may require maximizing the window first before the fullscreen mode works correctly.

2.1. Help wanted!

 

If anyone has an idea how to force windows to sit in front of the taskbar WITHOUT hiding the taskbar, please let me know. Currently most programs will correctly be in front when resized to fullscreen size (just like a browser when going into fullscreen mode) while some may not (observed only for Emacs so far). 

 

3. The script

#SingleInstance force

;;; Known issues:
;;;
;;; - Weird results for windows with custom decorations such as
;;; Chrome, or programs with a Ribbon interface.
;;; - Emacs will be maximized behind instead of in front of
;;; the taskbar. Workaround: WinHide ahk_class Shell_TrayWnd
ToggleFakeFullscreen()
{
CoordMode Screen, Window
static WINDOW_STYLE_UNDECORATED := -0xC40000
static savedInfo := Object() ;; Associative array!
WinGet, id, ID, A
if (savedInfo[id])
{
inf := savedInfo[id]
WinSet, Style, % inf["style"], ahk_id %id%
WinMove, ahk_id %id%,, % inf["x"], % inf["y"], % inf["width"], % inf["height"]
savedInfo[id] := ""
}
else
{
savedInfo[id] := inf := Object()
WinGet, ltmp, Style, A
inf["style"] := ltmp
WinGetPos, ltmpX, ltmpY, ltmpWidth, ltmpHeight, ahk_id %id%
inf["x"] := ltmpX
inf["y"] := ltmpY
inf["width"] := ltmpWidth
inf["height"] := ltmpHeight
WinSet, Style, %WINDOW_STYLE_UNDECORATED%, ahk_id %id%
mon := GetMonitorActiveWindow()
SysGet, mon, Monitor, %mon%
WinMove, A,, %monLeft%, %monTop%, % monRight-monLeft, % monBottom-monTop
}
}

GetMonitorAtPos(x,y)
{
;; Monitor number at position x,y or -1 if x,y outside monitors.
SysGet monitorCount, MonitorCount
i := 0
while(i < monitorCount)
{
SysGet area, Monitor, %i%
if ( areaLeft <= x && x <= areaRight && areaTop <= y && y <= areaBottom )
{
return i
}
i := i+1
}
return -1
}

GetMonitorActiveWindow(){
;; Get Monitor number at the center position of the Active window.
WinGetPos x,y,width,height, A
return GetMonitorAtPos(x+width/2, y+height/2)
}

F12::ToggleFakeFullscreen()

4. Screenshots

I wanted to post one / some, but I failed to find out how to upload attachments...

 

Edits

2015-07-22

Found out that emacs behaves correctly when it is maxized first. 

Corrected the default hotkey in the description.

Remark on distraction free editing.



Skrell
  • Members
  • 384 posts
  • Last active: Jul 07 2016 05:03 PM
  • Joined: 23 Aug 2011

this looks promising, couple of suggestions:

1.  put some exceptions in for those applications that have modified the decorations

2.  add an option to maximize the window and exclude the taskbar area.

 

You can't post attachments btw, but you can host the file(s) elsewhere and then link to them ;)



NewUser2015
  • Members
  • 7 posts
  • Last active: Dec 03 2015 10:03 PM
  • Joined: 06 Apr 2015

how do i make my program go full?



tweed
  • Members
  • 1 posts
  • Last active: Apr 21 2015 02:28 AM
  • Joined: 19 Dec 2014

Thank you - great work!
 

I believe the single key to hit now is F12

I tried (as above)   Default: Ctrl+Shift+F11
though i may have missed something.
F12 seems to be it which is written at the bottom of the script, opened and read with any text editor of course.
 



Klaus2
  • Members
  • 7 posts
  • Last active: Dec 01 2018 02:59 PM
  • Joined: 01 Sep 2012

this looks promising, couple of suggestions:

1.  put some exceptions in for those applications that have modified the decorations

2.  add an option to maximize the window and exclude the taskbar area.

 

You can't post attachments btw, but you can host the file(s) elsewhere and then link to them ;)

 

Ad 1.: While possible, it would require maintaining a list that differs by user anyway. I think its easier to leave it to each use to just not use it for programs where it doesn't work well enough (and even wether the result is "good enough" will differ by user). 

Ad 2.: I'll probably do this when I have the time  :S It would certainly make it more reliable.

Edit: It turns out that maximizing before toggling the fake-fullscreen state causes the window to flicker, so I'll leave it as it is.