Help to resize a VN window

tortank

New Member
Apr 13, 2018
3
1
Hello

I have a problem concerning a display of a window, in full screen I have access to the lower part of the screen which allows me to save and access the options but if I want to play with the minimized window, I lose access to the lower part which is problematic because I can no longer save or see the options. I tried several tools like ResizeEnable, Appresizer ,Scott's Window, or window resizer in order to solve it , but the problem persists I can not solve the problem. Do you have a solution ?

vn no.png

Thank you for your help
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,374
15,287
[...] but the problem persists I can not solve the problem. Do you have a solution ?
Your screenshot clearly show that the game, at least, don't take count of the game title bar and task bar when computing the size of the display. But I guess, from your previous attempt, that it goes further than that, and that , in fact, it don't bother to resize its own content to fit the new window size. I doubt that there's software for that, so, except buying a monitor with a bigger resolution, there's probably no solution to this problem ; something alas too frequent.
 
  • Like
Reactions: tortank

NylonPerson

New Member
Mar 4, 2018
9
6
Same problem here, also looking for a solution.

EDIT: I have succes with lowering my resolution to a size I want the window to be then running the game in fullscren with it already being set in DxWnd to force it into a window. The game will run in a window and I would reset the resolution back to it's recommended default. The window is in a better size but it cuts the content (the lower resolutions would cut more of the content), just using DxWnd directly for force a windowed mode would just make a windowed screen with a TON of the content locked.
 
Last edited:

NylonPerson

New Member
Mar 4, 2018
9
6
I think this warrants a new reply, mods can check.

I have been trying to recover an old trick I used to do with running older VMs in windows XP which always run in fullscreen mode (Nocturnal Illusions I think) where a used an specific DLL for GameMaker 6 to embed the window inside. It was old but I remembered it work so I set about finding those things. Thankfully there was a mirror of the said DLL and there is a patch to GM6 to make it run under windows 10, so long story short I kinda made it work

Here is how it looks like before:

Animation.gif


Here's how it looks like now:

nowWorking.gif

There is still some problems with it though: it isn't fully automated yet, and the resize is based on screen resolutions (I mainly use 800x600 though I am not sure what other resolutions are supported. It is wonky as fuck, will kinda break if you close the window without closing the game first and after the initial resize of the game window, you will still have to manually resize the wrapper window (the grey bars at the bottom).

Will try to upload a semi-automatic version.
 
  • Like
Reactions: anne O'nymous

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,374
15,287
Will try to upload a semi-automatic version.
At worse, MP a mod about this.
With too many Unity/Unreal games not fully, or not at all, taking count of the effective resolution of the screen, this can be good addition to the tools section of the site.
 

NylonPerson

New Member
Mar 4, 2018
9
6
Done with a simple python script that kinda works, just change required values. gm6 have some compatability problems in newer versions (you have to manually set compatability mode because the dll was old) had to do hack in python. This does NOT actually resize the game but just embeds a fullscreen game running under a lower resolution into a window and then returning the resolution to native.

Needed because I already tried several resizers and they just resized the window frame, but not the actual rendered image inside the frame (Lilith games mostly)

Python:
from tkinter import *
import subprocess, psutil, threading
import os, win32gui, win32process, time
import win32con, pywintypes, win32api
import win32ui, easygui, sys


# Sample settings for VN's using LEProc.exe
# Just change these values
prog = "T:\Path\To\Locale Emulator\LEProc.exe"
args = '"T:\Path\To\Actual\Game\With\The\Executable\LPK-12010.exe"'
exeName = "LPK-12010.exe"
progFull = f'{prog} {args}'
screen_win_width = 800
screen_win_height = 600
frame_win_width = 800
frame_win_height = 600

def get_pid_by_exe(exe=''):
    for proc in psutil.process_iter(['pid','exe']):
        try:
            if os.path.basename(proc.exe()).lower() == exe.lower():
                return proc.pid
        except psutil.AccessDenied:
            pass
    return None

# https://stackoverflow.com/q/51418928
def get_hwnds_for_pid (pid):
    def callback (hwnd, hwnds):
        # EDITED TO IMMEDIATELY GET THE PROGRAM
        #if win32gui.IsWindowVisible (hwnd) and win32gui.IsWindowEnabled (hwnd):
        _, found_pid = win32process.GetWindowThreadProcessId (hwnd)
        if found_pid == pid:
            hwnds.append (hwnd)
        return True
    hwnds = []
    win32gui.EnumWindows (callback, hwnds)
    return hwnds

def pid_thread(pid):
    while psutil.pid_exists(pid):
        time.sleep(0.5)
        pass
    os._exit(1)

# Create frame window
window = Tk()
window.title("Frame App")
window.iconbitmap(default='.\main.ico')
window.configure(width=frame_win_width, height=frame_win_height)
window.configure(bg='lightgray')
frame_window_handle = window.winfo_id()

print("opening process")
subprocess.Popen(progFull)

print("waiting process to load")
while get_pid_by_exe(exeName) is None:
    pass

print("process loaded")
gamePID = get_pid_by_exe(exeName)
p = psutil.Process(gamePID)

# Game close thread
closeThread = threading.Thread(target=pid_thread, args=(gamePID,),daemon=True)
closeThread.start()

# Get Game ICON KINDA NOT WORKING
#ico_x = win32api.GetSystemMetrics(win32con.SM_CXICON)
#ico_y = win32api.GetSystemMetrics(win32con.SM_CYICON)
#large, small = win32gui.ExtractIconEx(psutil.Process(gamePID).exe(),0)
#win32gui.DestroyIcon(small[0])
#hdc = win32ui.CreateDCFromHandle( win32gui.GetDC(0) )
#hbmp = win32ui.CreateBitmap()
#hbmp.CreateCompatibleBitmap( hdc, ico_x, ico_x )
#hdc = hdc.CreateCompatibleDC()
#hdc.SelectObject( hbmp )
#hdc.DrawIcon( (0,0), large[0] )
#hbmp.SaveBitmapFile( hdc, 'icon.ico')

# wait until handles are loaded
handles = get_hwnds_for_pid(gamePID)
oldlen = len(handles)
sec = 0
startTime = time.time()
while True:
    handles = get_hwnds_for_pid(gamePID)
    if len(handles) != oldlen:
        oldlen = len(handles)
        break
    lapseTime = time.time()
    sec = lapseTime - startTime
    if sec >= 5: break

game_window_handle = get_hwnds_for_pid(gamePID)[0]
# Pass close to the child window
window.protocol("WM_DELETE_WINDOW", lambda: {win32gui.PostMessage(game_window_handle,win32con.WM_CLOSE,0,0)})
# Change title to window title and ICON
window.title(win32gui.GetWindowText(game_window_handle))
#window.iconbitmap(default='.\icon.ico')

# RESIZE WINDOW
devmode = pywintypes.DEVMODEType()
devmode.PelsWidth = screen_win_width
devmode.PelsHeight = screen_win_height
devmode.Fields = win32con.DM_PELSWIDTH | win32con.DM_PELSHEIGHT
win32api.ChangeDisplaySettings(devmode, 0)

def hide_icon():
    for item in get_hwnds_for_pid(gamePID):
        #Hide game taskbar icon
        try:
            if win32gui.IsWindowVisible(item):
                #win32gui.ShowWindow(item, SW_HIDE)
                win32gui.SetWindowLong(item, win32con.GWL_EXSTYLE, win32gui.GetWindowLong(item, win32con.GWL_EXSTYLE)| win32con.WS_EX_TOOLWINDOW)
                win32gui.ShowWindow(item, win32con.SW_SHOW)
        except win32gui.error:
            print("error hiding icon")


# Center Window
window.eval('tk::PlaceWindow . center')
# Connect the window
window.after(100,hide_icon)
window.after(200,lambda: {win32gui.SetParent(game_window_handle,frame_window_handle)})
# Reset the screen and frame geometry
window.after(300,lambda: {win32api.ChangeDisplaySettings(None, 0)})
window.after(1000,lambda: {window.geometry(f'{frame_win_width}x{frame_win_height}')})
# Start the main frame window
window.mainloop()
There maybe some problems with the timings when the window is embedded and when the geometry is resized back, sometimes it would not catch it.