Skip to content

Spectacle/Rectangle for Windows: Hotkey-driven window snapping for Windows 10/11.

License

Notifications You must be signed in to change notification settings

phoeagon/RectangleWin

 
 

Repository files navigation

RectangleWin

A minimalistic Windows rewrite of macOS Rectangle.app/Spectacle.app. (Why?)

A hotkey-oriented window snapping and resizing tool for Windows.

This animation illustrates how RectangleWin helps me move windows to edges and corners (and cycle through half, one-thirds or two thirds width or height) only using hotkeys:

RectangleWin demo

Install

  1. Go to Releases and download the suitable binary for your architecture (typically x64).

  2. Launch the .exe file. Now the program icon should be visible on system tray!

  3. Click on the icon and mark as "Run on startup" to make sure you don't have to run it every time you reboot your PC.

Keyboard Bindings

  • Snap to edges (left/right/top/bottom ½, ⅔, ⅓):

    • Win + Alt +
    • Press multiple times to alternate between ½, ⅔ and ⅓.
  • Corner snapping

    • Win + Ctrl + Alt + : top-left ½, ⅔ and ⅓
    • Win + Ctrl + Alt + : top-right ½, ⅔ and ⅓
    • Win + Ctrl + Alt + : bottom-left ½, ⅔ and ⅓
    • Win + Ctrl + Alt + : bottom-right ½, ⅔ and ⅓
  • Center window on the display: Win+Alt+C

  • Maximize window: Win+Shift+F (Obsolete since Windows natively supports Win+)

  • Always On Top (toggle): Win+Alt+A

The following are also available if you use the attached config.yaml:

  • Ctrl + Alt + Shift + : maximize window height.

Why?

It seems that no window snapping utility for Windows is capable of letting user snap windows to edges or corners in {half, two-thirds, one-third} sizes using configurable shortcut keys, and center windows in a screen like Rectangle.app does, so I wrote this small utility for myself.

I've tried the native Windows shortcuts and PowerToys FancyZones and they are not supporting corners, alternating between half and one/two thirds, and are not offering enough hotkey support.

Roadmap

  • Configurable shortcuts: I don't need these and it will likely require a pop-up UI, so I will probably not get to this.

Configuration

Configuration could be achieved by changing config.yaml in the same folder.

This file has the following structure:

keybindings:
    - modifier:
        - Ctrl
        - Alt
      key: UP_ARROW
      bindfeature: moveToTop
      
    - modifier:
        - Ctrl
        - Alt
      key: DOWN_ARROW
      bindfeature: moveToBottom
      

Each element of keybindings define a feature to bind keys. Here are some valid modifiers:

  • Ctrl
  • Alt
  • Shift
  • Win

Here are some valid key:

/* case insensitive*/
a
b
...
c 

0
...
9

UP_ARROW
DOWN_ARROW
LEFT_ARROW
RIGHT_ARROW

+
"-" // This one has to be escaped

Here are some valid bindfeatures:

//   moveToTop
//   moveToBottom
//   moveToLeft
//   moveToRight
//   moveToTopLeft
//   moveToTopRight
//   moveToBottomLeft
//   moveToBottomRight
//   makeSmaller
//   makeLarger
//   makeFullHeight

See conf.go for more details.

The config.example.yaml contains an example. In addition, this YAML makes the following hotkey assignments available:

  • Ctrl + Alt + : snap to left half

  • Ctrl + Alt + : snap to right half

  • Ctrl + Alt + : snap to upper half

  • Ctrl + Alt + : snap to bottom half

  • Ctrl + Alt + U: top-left ½, ⅔ and ⅓

  • Ctrl + Alt + I: top-right ½, ⅔ and ⅓

  • Ctrl + Alt + J: bottom-left ½, ⅔ and ⅓

  • Ctrl + Alt + K: bottom-right ½, ⅔ and ⅓

Development (Install from source)

With Go 1.17+ installed, clone this repository and run:

go generate
GOOS=windows go build -ldflags -H=windowsgui .

The RectangleWin.exe will be available in the same directory.

License

This project is distributed as-is under the Apache 2.0 license. See LICENSE.

If you see bugs, please open issues. I can't promise any fixes.

About

Spectacle/Rectangle for Windows: Hotkey-driven window snapping for Windows 10/11.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%