Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Move window to half / quarter of current monitor


  • Please log in to reply
1 reply to this topic
MrMaxP
  • Members
  • 1 posts
  • Last active: Apr 10 2015 06:33 PM
  • Joined: 01 May 2014

I wanted to be able to set a window to the top half or bottom half of a monitor just like windows 7 can do with left and right. I couldn't find a good script that worked well with my 3 monitor landscape / portrait layout. So I wrote one.

 

This uses by default the windows key and the cursor keys to put a window in the top, bottom, left or right half of the current monitor (Which monitor is decided by a point 20 pixels down from the centre of the current window titlebar). Using the windows key and the keypad it also does quarter screen positioning with 1,3,7 and 9 along with half screen positioning with 2, 4, 6, 8. Windows numpad 5 switched between full screen and minimised.

 

It's a simple script and the keys can easily be changed or disabled if they interfere with windows keys that you prefer.

 

Enjoy.

; Script to allow positioning of windows based on quadrants of the current monitor

#Numpad1::
#End::
	MoveIt(1)
	return

#Numpad2::
#Down::
	MoveIt(2)
	return

#Numpad3::
#PgDn::
	MoveIt(3)
	return
	
#Numpad4::
#Left::
	MoveIt(4)
	return

#Numpad5::
#Enter::
	MoveIt(5)
	return

#Numpad6::
#Right::
	MoveIt(6)
	return

#Numpad7::
#Home::
	MoveIt(7)
	return

#Numpad8::
#Up::
	MoveIt(8)
	return

#Numpad9::
#PgUp::
	MoveIt(9)
	return

MoveIt(Q)
{
  ; Get the windows pos
	WinGetPos,X,Y,W,H,A,,,
	WinGet,M,MinMax,A
  
  ; Calculate the top center edge
  CX := X + W/2
  CY := Y + 20
  
;  MsgBox, X: %X% Y: %Y% W: %W% H: %H% CX: %CX% CY: %CY% 

  SysGet, Count, MonitorCount

  num = 1
  Loop, %Count%
  {
    SysGet, Mon, MonitorWorkArea, %num%

    if( CX >= MonLeft && CX <= MonRight && CY >= MonTop && CY <= MonBottom )
    {
		MW := (MonRight - MonLeft)
		MH := (MonBottom - MonTop)
		MHW := (MW / 2)
		MHH := (MH / 2)
		MMX := MonLeft + MHW
		MMY := MonTop + MHH
	
		if( M != 0 )
			WinRestore,A
		
		if( Q == 1 )
			WinMove,A,,MonLeft,MMY,MHW,MHH
		if( Q == 2 )
			WinMove,A,,MonLeft,MMY,MW,MHH
		if( Q == 3 )
			WinMove,A,,MMX,MMY,MHW,MHH
		if( Q == 4 )
			WinMove,A,,MonLeft,MonTop,MHW,MH
		if( Q == 5 )
		{
			if( M == 0 )
				WinMaximize,A
			else
				WinRestore,A
		}
		if( Q == 6 )
			WinMove,A,,MMX,MonTop,MHW,MH
		if( Q == 7 )
			WinMove,A,,MonLeft,MonTop,MHW,MHH
		if( Q == 8 )
			WinMove,A,,MonLeft,MonTop,MW,MHH
		if( Q == 9 )
			WinMove,A,,MMX,MonTop,MHW,MHH
        return
    }

    num += 1
  }
  
return
}



Leef_me
  • Moderators
  • 8510 posts
  • Last active: Sep 10 2015 05:50 AM
  • Joined: 08 Apr 2009

Your script is nice and much appreciated.

 

IMO, the 1,3,7,9 keys are the best.