Save and restore positions of windows, WindowsPosSaveNRestore

WindowsPosSaveNRestore is a tool to save the position of windows for later restore

This is primarily useful if you frequently change display configuration, say add/remove external monitor(s) e.g. by docking, or turning a device with autorotate active.

Windows also has the bug that it sometimes cram all open windows (and icons [+]) on the primary screen on sleep.

It saves positions in an XML-file, in a section index by a key containing the current screen-configuration
(More readably available saved in subkey DisplayInformation)
e.g.:

<Tot_X_-636_Y_-2160_Width_3840_Height_3600_List_X_0_Y_0_Width_2560_Height_1390_X_-636_Y_-2160_Width_3840_Height_2160>
   <DisplayInformation>
     <Vitual>{X=-636,Y=-2160,Width=3840,Height=3600}</Vitual>
     <Display>{X=0,Y=0,Width=2560,Height=1390}</Display>
     <Display>{X=-636,Y=-2160,Width=3840,Height=2160}</Display>
   </DisplayInformation>

 

Reflecting this logical configuration:

Note the height of the primary display. As I have taskbar always on, this is the physical height minus the height of the taskbar scaled with the scale factor of the monitor (with current size and scale ths gives 140 – 40 * 125%).

To initiate you select the window(s) you want to save in the lower pane, and clicks save.

To restore position(s) you can later select the saved items, and choose restore.

The app can be used with * and ? wildcards in the masks – you would need to edit the WindowsPosSaveNRestore.XML created manually to do so.
(Typical examples are apps that reflects the active document in the window title, and you might like that part replaced with an asterisk for ‘anything’, for programs where you do not have several instances opened simultaneously)

If you save a process that is matching an existing mask, only the placement is updated, not the masks.

Example node

<Process>
  <ProcessName>firefox</ProcessName>
  <Path>*\\Mozilla Firefox\\firefox.exe</Path>
  <Title>*Mozilla Firefox</Title>
  <flags>0</flags>
  <Placement>
    <showWCmd>Normal</showWCmd>
    <Left>-636</Left>
    <Top>-1085</Top>
    <Right>1260</Right>
    <Bottom>-1</Bottom>
  </Placement>
</Process>

Note that coordinates are STRETCHED if Windows is not set for 100% under Display Settings and that they can be negative, for secondary monitors logically above or left of the primary.
If you use BLANK in the masks for ProgramName, Path or Title, it will match anything.
Do not use blank in all three unless you want EVERY window to be displayed on top of each other – could make sense under rare circumstances, e.g. with all windows maximized.

 

The Rename Screen Settings is to change the system-generated name of the monitor constellation with something more user-readable. It is checked to be a valid XML key, so no fancy stuff!! A-Z, a-z, 0-9, underscore, minus and period should be accepted. Most begin with letter or underscore.

The 3s Focus Selected is to cycle through the selected processes, and show each window for *surprise* 3 seconds, before returning to the program

 

The source is quite simple C#, with no fancy stuff. (the most ‘fancy’ is that the checkboxlist are filled not with plain text, but with objects with a ToString() override function for what is displayed in the lists)

Source: WindowsPosSaveNRestore_Source

Exe: WindowsPosSaveNRestore_EXE

 

Please fell free to add any suggestions in the comment below – no guarantee it will be implemented though.

 

I have updated it with a few lines of code to make it “Per Monitor DPI Aware“, see other post here. So no more woolly scaling. but odd results if the primary monitor was not 100% at login….

 

It an be called with a /RestoreAll=<SectionID> option, Where <SectionId> is the name of the outer section, Note that this section can be renamed
e.g. <fullpath>\WindowsPosSaveNRestore.exe /RestoreAll=Disp_100pctQHD_100pctUHD

 

If you experience problems, please try this older Beta, as a first resort, to help debug.

BETA Exe: WindowsPosSaveNRestore_BETA_EXE

 

[+] For restoring icons I recommend: https://www.softwareok.com/?Freeware/DesktopOK