GithubHelp home page GithubHelp logo

binzgi / winpos Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 2.0 207 KB

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

License: MIT License

C# 100.00%

winpos's Introduction

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.

winpos's People

Contributors

binzgi avatar dependabot[bot] avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

winpos's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.