Sunday 26 May 2013

World of Tanks in Borderless Windowed Mode


Borderless Windowed Mode is a magical mechanism that lets you play full screen while still having access to your desktop. Say goodbye to Alt-Tabbing. No more waiting for windows to change resolution and reinitialize all the screens, no more losing sight of your game when all you wanted to do was to quickly reply to a PM. Do you have second monitor? Dont you just love how moving mouse pointer to second monitor and clicking automatically Alt-Tabs you out of the game? Well, no more of that either!

What you get instead is game seemingly rendered into desktop wallpaper. It really feels like magic. You can have Web browser and instant message on top of the game. Perfect for people that prefer to do 10 things at once!
  My favorite trick is to set game window to be one pixel smaller than monitor resolution and set windows Taskbar to auto-hide. This way we get for example 1599x1200 game window plus one pixel worth of vertical taskbar on the right edge of the screen.




I can browse interwebs while waiting for the map to load/clanwar to start :o). Perfect!

Python script:

import win32gui
from win32con import GWL_STYLE, WS_CAPTION, WS_SIZEBOX, WS_DLGFRAME, WS_THICKFRAME
import time
import os

def main():
    os.system("start \"..\" G:\\World_of_Tanks\\xvm-stat.exe")

#   option = combination of those four: WS_CAPTION, WS_SIZEBOX, WS_DLGFRAME, WS_THICKFRAME
    option = WS_CAPTION + WS_SIZEBOX
#   window_name = name that appears on application title bar
    window_name = "W.o.T. Client"

    time.sleep(5)
    for x in range(60):
      time.sleep(1)
      hwnd = win32gui.FindWindow(None, window_name)
      if hwnd !=0:
        win32gui.MoveWindow(hwnd, 0,0,1599,1200, True)
        gwl = win32gui.GetWindowLong(hwnd, GWL_STYLE)
        win32gui.SetWindowLong(hwnd, GWL_STYLE, (gwl ^ option))
        break

if __name__ == '__main__':
    main()

You also need to edit your preferences.xml file located at
 C:\Documents and Settings\Administrator\Application Data\wargaming.net\WorldOfTanks\preferences.xml  (XP)
 %APPDATA%\Wargaming.net\WorldOfTanks\preferences.xml  (Vista/7/8)

Change those settings:
    <windowed> true </windowed>
    <windowedWidth> 1599 </windowedWidth>
    <windowedHeight> 1200 </windowedHeight>
according to your needs.

  From now on you can start WoT by just clicking on minimize.py script.

Ps: I wrote this script because Im to lazy to press Autohotkey bind every time I start the game, and Im too paranoid to run third party executables written by some random Russian dude :) Not to mention I dont like programs sitting in my taskbar doing nothing and eating ram. This script quits as soon as it finishes its job of making the game windowed = no wasted ram or cpu cycles. Plus its open source so everyone can see whats going on and there is no danger of trojans/viruses.