• How To?
  • Tips ‘n Tricks
  • WordPress
  • Snippets
  • Software
    • Browsers
    • Downloads
  • Web
  • Tools
    • Character Counter
    • chmod Calculator
    • Entities Encoder
    • Live HTML Editor
    • My IP
  • Contact
Twitter Facebook Google+ RSS
You are here: SumTips » Tips 'n Tricks » Snap a Window to Top or Bottom of the Screen

Snap a Window to Top or Bottom of the Screen

Posted on May 29, 2012 by Renji | Short URL: http://sumtips.com/?p=6745

Microsoft Windows 7 has a handy Snap feature that allows you to arrange open windows, including maximizing and resizing, just by dragging and dropping a window to different edges of the screen. When a window is dragged to the edge, Windows will display a glass overlay on the desktop. As soon as you let go of the mouse button, it will snap the window onto that overlay. This can also be done with keyboard shortcuts:

  • Win+Left: Snap window to the left
  • Win+Right: Snap window to the right
  • Win+Up: Maximize window
  • Win+Down: Restore/Minimize window

But what if you want to snap a window to top half of the screen, and another window on bottom half? There’s no built-in shortcut that does this.

If you are annoyed with this limitation, here’s a AutoHotkey script, by Ben Northway, that will give you these features:

; Move window up
+#Up::
  WinGetPos,X,Y,W,H,A,,,
  WinMaximize
  WinGetPos,TX,TY,TW,TH,ahk_class Shell_TrayWnd,,,

  ; if this is greater than 1, we're on the secondary (right) monitor. This means the center of the active window is a positive X coordinate
  if ( X + W/2 > 0 ) {
  SysGet, MonitorWorkArea, MonitorWorkArea, 1
  WinMove,A,,X,0 , , (MonitorWorkAreaBottom/2)
  }
  else {
  SysGet, MonitorWorkArea, MonitorWorkArea, 2
  WinMove,A,,X,0 , , (MonitorWorkAreaBottom/2)
  }  
return

; Move window down
+#Down::
  WinGetPos,X,Y,W,H,A,,,
  WinMaximize
  WinGetPos,TX,TY,TW,TH,ahk_class Shell_TrayWnd,,,

  ; if this is greater than 1, we're on the secondary (right) monitor. This means the center of the active window is a positive X coordinate
  if ( X + W/2 > 0 ) {
  SysGet, MonitorWorkArea, MonitorWorkArea, 1
  WinMove,A,,X,MonitorWorkAreaBottom/2 , , (MonitorWorkAreaBottom/2)
  }
  else {
  SysGet, MonitorWorkArea, MonitorWorkArea, 2
  WinMove,A,,X,MonitorWorkAreaBottom/2 , , (MonitorWorkAreaBottom/2)
  }
return

With the script running, press these shortcuts:

  • Win+Shift+Up: Snap window to the top
  • Win+Shift+Down: Snap window to the bottom

Snap Window to Top or Bottom

You can customize the script to work with any other keyboard key combinations easily. You just have to edit these two parts in the code: +#Up:: and +#Down::

If you rather have a EXE file, Ben has put it up on his website for download as well.

To run the program with Windows, add a shortcut to the program to your Startup folder on the Start menu.


Tweet

Related posts:

  • Move Minimize, Maximize & Close Buttons to The Left of a Window
  • Super Maximize Windows To Your Screen
  • Always Open Programs in Predefined Position and Window Size
  • Disable Portable Apps Splash Screen
  • Show Pressed Keyboard Keys and Mouse Clicks on Screen
Categories: Tips 'n Tricks | Tags: AutoHotkey Snippets, Tips 'n Tricks, Windows 7, Windows 8
Automatically Switch Windows Theme When on Laptop Battery
Delete Files Based on Extension, Attribute in Folders & Subfolders

  • Get Updates via Email

  • Recent Posts

    • CMS2CMS: Migrate Site from Drupal or Joomla to WordPress
    • WordPress: Add Preview Button in Distraction Free Writing
    • How to Activate or Deactivate Individual Jetpack Modules
    • Windows 8: Auto Update Defender with Windows Update Disabled
    • Automatically Start and Close Programs at Specific Time
    • How to Copy Code from Notepad++ with Syntax Highlighting
  • Random Posts

    • Yahoo Messenger for Android, iPhone to Support Video Calling
    • Increase WordPress File Upload Size Limit on Shared Hosts
    • Sony Ericsson X10 and X10 Mini Pro to Finally Get Android 2.1
    • Convert Font Online with Free Font Converter
    • Give Your Site Visitors a Quick Print Preview Option, Ctrl+P Hotkey
    • Block Accidental Taps and Clicks While Typing on Laptops
  • Categories

    • Blogging
    • Games
    • Google
    • How To?
    • Linux
    • Microsoft
      • Windows
    • Miscellaneous
    • Phone
    • Snippets
      • AutoHotkey Snippets
      • CSS Snippets
      • htaccess Snippets
      • JavaScript Snippets
      • PowerShell Snippets
      • WordPress Snippets
    • Social
    • Software
      • Browsers
    • Tips 'n Tricks
    • Wallpapers
    • Web
© SumTips. Contact | Sitemap | Privacy Policy