Skip to content
/ WinPos Public

WinPos is handy tool for Microsoft Windows that can save and restore windows size, position and states through Windows API calls.

License

Notifications You must be signed in to change notification settings

BiNZGi/WinPos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome to WinPos

WinPos is handy tool for Microsoft Windows that can save and restore windows size, position and states through Windows API calls. The data is stored as JSON in %LOCALAPPDATA%\WinPos\WinPos.json file.

Requirements

This is probably already present with installation of Microsoft Windows. If you are unsure you can use the following in a command line to determine the installed versions:

wmic product get description | findstr /C:".NET Framework"

How to use

WinPos [save] [restore]
Option Description
save Save current window positions
restore Restore previously saved window positions

Examples

Save the current window positions into JSON file.

WinPos.exe save

Restore the window positions from JSON file.

WinPos.exe restore

Technical details

Save

  1. Interate through EnumWindows to get all current window handles.
  2. Call to GetWindowPlacement to get window details.
  3. If window is in normal state the position are determined by GetWindowRect. This allows to get the details of windows that are positioned by Windows Snap.
  4. Write JSON file with the following details:
  • Handle
  • Title
  • WindowPlacement
    • Length
    • Flags
    • ShowCmd
    • PtMinPosition
    • PtMaxPosition
    • RcNormalPosition

Restore

  1. Read window data from JSON file according chapter save.
  2. Iterate through data.
  3. Call SetWindowPlacement using handle with the WindowPlacement details.

Remark: If the window handle has changed somehow the window cannot be found and is not repositioned.

Third party libraries

License

WinPos is open source under the MIT License and is free for commercial use.

About

WinPos is handy tool for Microsoft Windows that can save and restore windows size, position and states through Windows API calls.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages