7

I recently upgraded to Windows 10 on my home PC. In Windows 7 I had a few startup programs that I used often set to open on a second monitor at startup. These programs would always open in the same location with the same size. I assume this is a feature of both Windows and/or the program itself.

In Windows 10 I have noticed that some programs do not display this behavior. They specifically are opened in the same location, but 10-20px shorter in the horizontal direction. For example, on start up (or even during general usage) I will horizontally maximize Windows explorer.exe. When explorer is then opened again though, 10-20px of width are taken from the left and right side of the window

enter image description here

In the image above, the top portion shows explorer opened and horizontally maximized. The bottom shows explorer opened again after closing and its default location and size set by (I assume) Windows. (The light blue is image background, black is "no man's land" in desktop space, the dark gray is my desktop background, the red lines show the general location of the missing width of the window).


How can I force Windows 10 to truly and always open programs in the exact same location with the exact same size?

Note, some programs do not have this issue. Specifically Firefox, it will always open in the exact same location with the exact same size. Though I am wholly certain this is a feature of Firefox. Given explorer.exe is Windows', then I know this issue is on Windows' end too.

4
  • 1
    Though not an answer to your question - AutoHotKey can probably be used to do what you are trying to do. autohotkey.com/docs/commands/WinMove.htm – BobtheMagicMoose Dec 13 '19 at 17:15
  • Also, this opens at the exact same size for me. Could be something unique to your system. – BobtheMagicMoose Dec 13 '19 at 17:24
  • back the day, closing a window with <kbd>Ctrl</kbd> + <kbd>Alt</kbd> + <kbd>Shift</kbd> keys pressed, would make that application open with that exact same size and position :) – balexandre Dec 14 '19 at 9:58
  • Did you check if the secondary screen on windows7 and windows10 is recognized with the same pixel width? Or if for a completely new (different) user the problem persists? The second check can tell you if it is a problem in some value saved in your user settings, the first one if the new OS version needs to have fixed the pixel of the screen... – Hastur Dec 20 '19 at 10:20
4
+150

A free tool exists that uses the script language of AutoHotkey.

A user named gallaxhar has created a script in the post Automatically Restore Last Window Position For Each Process that acts as an automatic window manager that saves window positions with no user input or setup. It works by getting the current active window information (id and processname). It saves the latest window size/pos to an ini file, and reads from that file when new window IDs become active. It will auto-size only windows from after it is run, it will only autosize new ID's, and it will only do so one time for that ID.

After installing AutoHotkey, place the script in an .ahk file. Test by double-click to launch. It will have a green "H" icon in the traybar, which you may right-click to Exit. Once proven as working correctly, you may place it in your Startup folder.

I tested the script and it seems to work in your scenario.

The script is reproduced here:

; Automatically Restore Previous Window Size/Pos

; To make this script run when windows starts, make sure RegistryAdd.ahk is in the same directory as this script, run this script, and it will be added to the registry. Then delete RegistryAdd.ahk
#Include *i RegistryAdd.ahk

; To easily remove the previously added registry entry, make sure RegistryRemove.ahk is in the same directory as this script, run this script, and it will be removed from the registry. Then delete RegistryRemove.ahk
#Include *i RegistryRemove.ahk

#SingleInstance Force
#Persistent
#NoEnv
;#NoTrayIcon
SetWinDelay, 50
Process, Priority, , Normal

MatchList := ""

; Build the MatchList
WinGet, id, list,,, Program Manager
Loop, %id%
{
    this_id := id%A_Index%
    if (MatchList = "")
    MatchList := this_id
    else
    MatchList := MatchList . "," . this_id 
}

; ExclusionList
ExclusionList = ShellExperienceHost.exe,SearchUI.exe

; The main program loop, which manages window positions/sizes and saves their last known configuration to an ini file in the script directory.
Loop,
{
    Sleep, 350
    WinGet, active_id, ID, A
    if active_id not in %MatchList% ; Then this is a new window ID! So, check if it has a configuration saved.
    {
        MatchList := MatchList . "," . active_id ; This window ID is not new anymore!
        WinGet, active_ProcessName, ProcessName, A
        WinGetClass, active_Class, A
        IniRead, savedSizePos, %A_ScriptDir%\WindowSizePosLog.ini, Process Names, %active_ProcessName%
        if (savedSizePos != "ERROR" AND active_Class != "MultitaskingViewFrame" AND active_class != "Shell_TrayWnd") ; Then a saved configuration exists, size/move the window!
        {
            StringSplit OutputArray, savedSizePos,`,
            if (active_ProcessName = "explorer.exe" AND active_Class != "CabinetWClass")
            {

            }
            else
            {
                WinMove, A,, OutputArray1, OutputArray2, OutputArray3, OutputArray4
            }
        }
        else ; No saved configuration exists, save the current window size/pos as a configuration instead!
        {
            WinGetPos X, Y, Width, Height, A
            WinGet, active_ProcessName, ProcessName, A
            WinGetClass, active_Class, A
            If (X != "" AND Y != "" AND Width != "" AND Height != "" AND Width > 0 AND Height > 0 AND active_Class != "MultitaskingViewFrame" AND active_class != "Shell_TrayWnd")
            {
                if (active_ProcessName = "explorer.exe" AND active_Class != "CabinetWClass")
                {

                }
                else if active_ProcessName not in %ExclusionList%
                {
                    IniWrite %X%`,%Y%`,%Width%`,%Height%, %A_ScriptDir%\WindowSizePosLog.ini, Process Names, %active_ProcessName%
                }
            }
        }
    }
    else ; Save/overwrite the active window size and position to a file with a link to the processname, for later use.
    {
        WinGetPos X, Y, Width, Height, A
        WinGet, active_ProcessName, ProcessName, A
        WinGetClass, active_Class, A
        If (X != "" AND Y != "" AND Width != "" AND Height != "" AND Width > 0 AND Height > 0 AND active_Class != "MultitaskingViewFrame" AND active_class != "Shell_TrayWnd")
        {
            if (active_ProcessName = "explorer.exe" AND active_Class != "CabinetWClass")
            {

            }
            else if active_ProcessName not in %ExclusionList%
            {
                IniWrite %X%`,%Y%`,%Width%`,%Height%, %A_ScriptDir%\WindowSizePosLog.ini, Process Names, %active_ProcessName%
            }
        }
    }
}
Return

A commercial tool that also remembers and restores the position and size of programs and windows is DeskSoft WindowManager (10$, trialware).

This tool will remember positions and sizes across reboots.

0
2

This problem is so old and so common that many different developers have released projects to cover the deficiency in Windows OS.

Many are free: http://www.stefandidak.com/windows-layout-manager/

or open source: https://github.com/lapo-luchini/WindowsLayoutSnapshot/tree/v1.3.0.0

Some people have noticed that if you move the start menu to the top, instead of the bottom, that Windows behaves differently.

You can also complain to Microsoft. This is something that should just work like it does in other window management systems available for Linux and MacOS. Use the feedback tool to complain: https://support.microsoft.com/en-us/help/4021566/windows-10-send-feedback-to-microsoft-with-feedback-hub-app

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.