Jump to content

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

Windows-7 Like Window Positioning for XP and Vista


  • Please log in to reply
80 replies to this topic
KooKsTeR
  • Members
  • 157 posts
  • Last active: Aug 21 2015 09:55 PM
  • Joined: 19 Feb 2010
Ok as far as I can tell this has no problems with remembering a windows original size, give it a run and let me know how it goes:

Version 1: After moving out of expanded area it will stay where you dropped it.
Version 2: After moving out of expanded area it will center on the mouse.

Please tell me which one you like more.

Version 1:
#NoEnv

Win__GetDesktopPos(ByRef X, ByRef Y, ByRef W, ByRef H)
   {
   WinGetPos, TrayX, TrayY, TrayW, TrayH, ahk_class Shell_TrayWnd
   if (TrayW = A_ScreenWidth)
      {
      ; Horizontal Taskbar
      X := 0
      Y := TrayY ? 0 : TrayH
      W := A_ScreenWidth
      H := A_ScreenHeight - TrayH
      }
   else
         {
         ; Vertical Taskbar
         X := TrayX ? 0 : TrayW
         Y := 0
         W := A_ScreenWidth - TrayW
         H := A_ScreenHeight
      }
   }

Win__HalfLeft()
   {
   wingetactivestats,ActiveTitle,Width,Height,x,Y
   winget,Title,ID,%ActiveTitle%
   ifexist,%title%.txt
      {
      filedelete,%title%.txt
      }
   fileappend,
(
%width%
%height%
),%title%.txt
   Win__GetDesktopPos(X, Y, W, H)
   WinMove, A,, X, Y, W/2, H
   }

Win__HalfRight()
   {   
   wingetactivestats,ActiveTitle,Width,Height,x,Y
   winget,Title,ID,%ActiveTitle%
   ifexist,%title%.txt
      {
      filedelete,%title%.txt
      }
   fileappend,
(
%width%
%height%
),%title%.txt
   Win__GetDesktopPos(X, Y, W, H)
   winMove, A,, X + W/2, Y, W/2, H
   }

Win__FullSize()
   {
   wingetactivestats,ActiveTitle,Width,Height,x,Y
   winget,Title,ID,%ActiveTitle%
   ifexist,%title%.txt
      {
      filedelete,%title%.txt
      }
   fileappend,
(
%width%
%height%
),%title%.txt
   Win__GetDesktopPos(X, Y, W, H)
   WinMove, A,, X, Y, W, H
   }


*~LButton::
    CoordMode, Mouse, Screen
    MouseGetPos, x, y, hwnd
    SendMessage, 0x84, 0, (x&0xFFFF) | (y&0xFFFF) << 16,, ahk_id %hwnd%
    RegExMatch("ERROR TRANSPARENT NOWHERE CLIENT CAPTION SYSMENU SIZE MENU HSCROLL VSCROLL MINBUTTON MAXBUTTON LEFT RIGHT TOP TOPLEFT TOPRIGHT BOTTOM BOTTOMLEFT BOTTOMRIGHT BORDER OBJECT CLOSE HELP", "(?:\w+\s+){" . ErrorLevel+2&0xFFFFFFFF . "}(?<AREA>\w+\b)", HT)
    if htarea!=CAPTION
      Return
    MouseGetPos,_x,_y
    While GetKeyState("LButton","P") && x=_x && y=_y ;Wait until user begins dragging
      MouseGetPos,_x,_y
    While GetKeyState("LButton","P") ;Show ToolTip while dragging
   {
   keywait,lbutton
   coordmode,mouse,screen
   MouseGetPos,Mouse_X,Mouse_Y
   if Mouse_X=0
      {
      Win__HalfLeft()
   return
      }
   Win__GetDesktopPos(X,Y,Width,Height)   
   Width-=5
   if (width < mouse_x)
      {
      Win__HalfRight()
   return
      }
   if mouse_y=0
      {
      Win__FullSize()
   return
      }
   WinGetActiveTitle,ActiveTitle
   winget,Title,ID,%ActiveTitle%
   ifexist,%title%.txt
      {
      filereadline,width,%title%.txt,1
      filereadline,height,%title%.txt,2
      filedelete,%title%.txt
      WinGetActiveTitle,ActiveTitle
      winmove,%ActiveTitle%,,,,%width%,%height%
      return
      }
   }
Return

#right::Win__HalfRight()
#left::Win__HalfLeft()
#up::Win__FullSize()

Version 2:
#NoEnv

Win__GetDesktopPos(ByRef X, ByRef Y, ByRef W, ByRef H)
   {
   WinGetPos, TrayX, TrayY, TrayW, TrayH, ahk_class Shell_TrayWnd
   if (TrayW = A_ScreenWidth)
      {
      ; Horizontal Taskbar
      X := 0
      Y := TrayY ? 0 : TrayH
      W := A_ScreenWidth
      H := A_ScreenHeight - TrayH
      }
   else
         {
         ; Vertical Taskbar
         X := TrayX ? 0 : TrayW
         Y := 0
         W := A_ScreenWidth - TrayW
         H := A_ScreenHeight
      }
   }

Win__HalfLeft()
   {
	wingetactivestats,ActiveTitle,Width,Height,x,Y
	winget,Title,ID,%ActiveTitle%
	ifexist,%title%.txt
		{
		filedelete,%title%.txt
		}
	fileappend,
(
%width%
%height%
),%title%.txt
   Win__GetDesktopPos(X, Y, W, H)
   WinMove, A,, X, Y, W/2, H
   }

Win__HalfRight()
   {   
	wingetactivestats,ActiveTitle,Width,Height,x,Y
	winget,Title,ID,%ActiveTitle%
	ifexist,%title%.txt
		{
		filedelete,%title%.txt
		}
	fileappend,
(
%width%
%height%
),%title%.txt
   Win__GetDesktopPos(X, Y, W, H)
   winMove, A,, X + W/2, Y, W/2, H
   }

Win__FullSize()
   {
	wingetactivestats,ActiveTitle,Width,Height,x,Y
	winget,Title,ID,%ActiveTitle%
	ifexist,%title%.txt
		{
		filedelete,%title%.txt
		}
	fileappend,
(
%width%
%height%
),%title%.txt
   Win__GetDesktopPos(X, Y, W, H)
   WinMove, A,, X, Y, W, H
   }


*~LButton::
    CoordMode, Mouse, Screen
    MouseGetPos, x, y, hwnd
    SendMessage, 0x84, 0, (x&0xFFFF) | (y&0xFFFF) << 16,, ahk_id %hwnd%
    RegExMatch("ERROR TRANSPARENT NOWHERE CLIENT CAPTION SYSMENU SIZE MENU HSCROLL VSCROLL MINBUTTON MAXBUTTON LEFT RIGHT TOP TOPLEFT TOPRIGHT BOTTOM BOTTOMLEFT BOTTOMRIGHT BORDER OBJECT CLOSE HELP", "(?:\w+\s+){" . ErrorLevel+2&0xFFFFFFFF . "}(?<AREA>\w+\b)", HT)
    if htarea!=CAPTION
      Return
    MouseGetPos,_x,_y
    While GetKeyState("LButton","P") && x=_x && y=_y ;Wait until user begins dragging
      MouseGetPos,_x,_y
    While GetKeyState("LButton","P") ;Show ToolTip while dragging
   {
   keywait,lbutton
   coordmode,mouse,screen
   MouseGetPos,Mouse_X,Mouse_Y
   if Mouse_X=0
      {
      Win__HalfLeft()
	return
      }
   Win__GetDesktopPos(X,Y,Width,Height)   
   Width-=5
   if (width < mouse_x)
      {
      Win__HalfRight()
	return
      }
   if mouse_y=0
      {
      Win__FullSize()
	return
      }
	WinGetActiveTitle,ActiveTitle
	winget,Title,ID,%ActiveTitle%
	ifexist,%title%.txt
		{
		filereadline,width,%title%.txt,1
		filereadline,height,%title%.txt,2
		filedelete,%title%.txt
		WinGetActiveTitle,ActiveTitle
		width2=%width%
		EnvDiv, width2, 2
		coordmode,mouse,screen
		MouseGetPos,Mouse_X
		mouse_x-=%width2%
		winmove,%ActiveTitle%,,%mouse_x%,,%width%,%height%
		return
		}
   }
Return

#right::Win__HalfRight()
#left::Win__HalfLeft()
#up::Win__FullSize()

~^s::
sleep 100
reload


gwarble
  • Members
  • 624 posts
  • Last active: Aug 12 2016 07:49 PM
  • Joined: 23 May 2009
nice work kookster and everyone...

i'm liking the fling effect of right click dragging with the following... right-click-dragging over 25 pixels in either direction does the right snap or left snap

any ideas how to get rid of the context menu?

*~RButton::
    CoordMode, Mouse, Screen
    MouseGetPos, x, y, hwnd
    SendMessage, 0x84, 0, (x&0xFFFF) | (y&0xFFFF) << 16,, ahk_id %hwnd%
    RegExMatch("ERROR TRANSPARENT NOWHERE CLIENT CAPTION SYSMENU SIZE MENU HSCROLL VSCROLL MINBUTTON MAXBUTTON LEFT RIGHT TOP TOPLEFT TOPRIGHT BOTTOM BOTTOMLEFT BOTTOMRIGHT BORDER OBJECT CLOSE HELP", "(?:\w+\s+){" . ErrorLevel+2&0xFFFFFFFF . "}(?<AREA>\w+\b)", HT)
    if htarea!=CAPTION
      Return
    MouseGetPos,_x,_y
    While GetKeyState("RButton","P") && x=_x && y=_y ;Wait until user begins dragging
      MouseGetPos,_x,_y
    While GetKeyState("RButton","P") ;Show ToolTip while dragging
   {
   keywait,rbutton
   coordmode,mouse,screen
   MouseGetPos,Mouse_X,Mouse_Y
   if (Mouse_X<_x-25)
      {
      Win__HalfLeft()
      }
   Else if (Mouse_X>_x+25)
      {
      Win__HalfRight()
      }
}
Return

also there's some confusion to the window when you drag to the edge while already maximized (ie then pressing what would normally be maximize is really the restore button, so it takes to clicks)

i would think manually overriding to "restored" and then resized to halfscreen size in the case of it already being maximized

or

when going to half size from "restored", set the window to maximized first then resize it (window corners look better with a theme applied) and then detect the "restore" button when in half mode and override it to maximize the half window (which is already technically maximized, but half size)

thanks
- gwarble

KooKsTeR
  • Members
  • 157 posts
  • Last active: Aug 21 2015 09:55 PM
  • Joined: 19 Feb 2010
Here is a new version that when you move a window from a maximized/half maximized position it will restore its prior size and center it on the mouse according to where you were holding the prior window. I know not much of a feature and it was a pain in the butt to do but i think it was worth it. Besides i like a challenge.

I also need to make a way to get rid of old files if a window is closed.

Here it is:
#NoEnv

Win__GetDesktopPos(ByRef X, ByRef Y, ByRef W, ByRef H)
   {
   WinGetPos, TrayX, TrayY, TrayW, TrayH, ahk_class Shell_TrayWnd
   if (TrayW = A_ScreenWidth)
      {
      ; Horizontal Taskbar
      X := 0
      Y := TrayY ? 0 : TrayH
      W := A_ScreenWidth
      H := A_ScreenHeight - TrayH
      }
   else
         {
         ; Vertical Taskbar
         X := TrayX ? 0 : TrayW
         Y := 0
         W := A_ScreenWidth - TrayW
         H := A_ScreenHeight
      }
   }

Win__HalfLeft()
   {
	wingetactivestats,ActiveTitle,Width,Height,x,Y
	winget,Title,ID,%ActiveTitle%
	ifexist,%title%.txt
		{
		filedelete,%title%.txt
		}
	fileappend,
(
%width%
%height%
),%title%.txt
   Win__GetDesktopPos(X, Y, W, H)
   WinMove, A,, X, Y, W/2, H
   }

Win__HalfRight()
   {   
	wingetactivestats,ActiveTitle,Width,Height,x,Y
	winget,Title,ID,%ActiveTitle%
	ifexist,%title%.txt
		{
		filedelete,%title%.txt
		}
	fileappend,
(
%width%
%height%
),%title%.txt
   Win__GetDesktopPos(X, Y, W, H)
   winMove, A,, X + W/2, Y, W/2, H
   }

Win__FullSize()
   {
	wingetactivestats,ActiveTitle,Width,Height,x,Y
	winget,Title,ID,%ActiveTitle%
	ifexist,%title%.txt
		{
		filedelete,%title%.txt
		}
	fileappend,
(
%width%
%height%
),%title%.txt
   Win__GetDesktopPos(X, Y, W, H)
   WinMove, A,, X, Y, W, H
   }


*~LButton::
    CoordMode, Mouse, Screen
    MouseGetPos, x, y, hwnd
    SendMessage, 0x84, 0, (x&0xFFFF) | (y&0xFFFF) << 16,, ahk_id %hwnd%
    RegExMatch("ERROR TRANSPARENT NOWHERE CLIENT CAPTION SYSMENU SIZE MENU HSCROLL VSCROLL MINBUTTON MAXBUTTON LEFT RIGHT TOP TOPLEFT TOPRIGHT BOTTOM BOTTOMLEFT BOTTOMRIGHT BORDER OBJECT CLOSE HELP", "(?:\w+\s+){" . ErrorLevel+2&0xFFFFFFFF . "}(?<AREA>\w+\b)", HT)
    if htarea!=CAPTION
      Return
    MouseGetPos,_x,_y
    While GetKeyState("LButton","P") && x=_x && y=_y ;Wait until user begins dragging
      MouseGetPos,_x,_y
    While GetKeyState("LButton","P") ;Show ToolTip while dragging
   {
   keywait,lbutton
   coordmode,mouse,screen
   MouseGetPos,Mouse_X,Mouse_Y
   if Mouse_X=0
      {
      Win__HalfLeft()
	return
      }
   Win__GetDesktopPos(X,Y,Width,Height)   
   Width-=5
   if (width < mouse_x)
      {
      Win__HalfRight()
	return
      }
   if mouse_y=0
      {
      Win__FullSize()
	return
      }
	WinGetActiveTitle,ActiveTitle
	winget,Title,ID,%ActiveTitle%
	ifexist,%title%.txt
		{
		filereadline,Originalwidth,%title%.txt,1
		filereadline,Originalheight,%title%.txt,2
		filedelete,%title%.txt
		WinGetActiveStats,ActiveTitle,total,CurrentHeight,p,p
		coordmode,mouse,relative
		MouseGetPos,given
		Part:= given / total
		Percent:= Part*100
		part2:= percent / 100
		part3:= part2*originalwidth
		coordmode,mouse,screen
		MouseGetPos,mouse_x
		Win__GetDesktopPos(X,Y,Width,Height) 
		final1:= width-mouse_x
		final2:= final1+part3
		final3:= width-final2
		winmove,%ActiveTitle%,,%final3%,,%originalwidth%,%originalheight%
		return
		}
   }
Return

#right::Win__HalfRight()
#left::Win__HalfLeft()
#up::Win__FullSize()

Pretty much at this point its the same as windows 7 version except the preview and when it enables the window size change, but I dont think i care enough about those ones to do them. I also dont have a clue how i would do that either.

KooKsTeR
  • Members
  • 157 posts
  • Last active: Aug 21 2015 09:55 PM
  • Joined: 19 Feb 2010
To get rid of the context menu just send esc
send,{esc}
You might see the menu for a split second but it will go away.

Like so:
*~RButton::
    CoordMode, Mouse, Screen
    MouseGetPos, x, y, hwnd
    SendMessage, 0x84, 0, (x&0xFFFF) | (y&0xFFFF) << 16,, ahk_id %hwnd%
    RegExMatch("ERROR TRANSPARENT NOWHERE CLIENT CAPTION SYSMENU SIZE MENU HSCROLL VSCROLL MINBUTTON MAXBUTTON LEFT RIGHT TOP TOPLEFT TOPRIGHT BOTTOM BOTTOMLEFT BOTTOMRIGHT BORDER OBJECT CLOSE HELP", "(?:\w+\s+){" . ErrorLevel+2&0xFFFFFFFF . "}(?<AREA>\w+\b)", HT)
    if htarea!=CAPTION
      Return
    MouseGetPos,_x,_y
    While GetKeyState("RButton","P") && x=_x && y=_y ;Wait until user begins dragging
      MouseGetPos,_x,_y
    While GetKeyState("RButton","P") ;Show ToolTip while dragging
   {
   keywait,rbutton
	send,{esc}  ;<-------------Send esc!!!!
   coordmode,mouse,screen
   MouseGetPos,Mouse_X,Mouse_Y
   if (Mouse_X<_x-25)
      {
      Win__HalfLeft()
      }
   Else if (Mouse_X>_x+25)
      {
      Win__HalfRight()
      }
}
Return

Now the other problem I'm not so sure what you mean.

KooKsTeR
  • Members
  • 157 posts
  • Last active: Aug 21 2015 09:55 PM
  • Joined: 19 Feb 2010
Also on a side note your info says you live in the north bay california? as in the bay area san francisco? if so we are pretty dang close Im just next door to san jose!

KooKsTeR
  • Members
  • 157 posts
  • Last active: Aug 21 2015 09:55 PM
  • Joined: 19 Feb 2010
Yet another version.
This time it wont center the window/mouse on a button like the minimize/max/close/whatever the one on the left is called. Not sure fool proof this code is, but it seems to be working. Getting it to work properly for the left button though is pretty dang annoying.

[*Re Updated*]
#NoEnv

Win__GetDesktopPos(ByRef X, ByRef Y, ByRef W, ByRef H)
	{
	WinGetPos, TrayX, TrayY, TrayW, TrayH, ahk_class Shell_TrayWnd
	if (TrayW = A_ScreenWidth)
		{
		X := 0
		Y := TrayY ? 0 : TrayH
		W := A_ScreenWidth
		H := A_ScreenHeight - TrayH
		}
	else
		{
		X := TrayX ? 0 : TrayW
		Y := 0
		W := A_ScreenWidth - TrayW
		H := A_ScreenHeight
		}
	}

Win__HalfLeft()
{
wingetactivestats,ActiveTitle,Width,Height,x,Y
winget,Title,ID,%ActiveTitle%
ifexist,%title%.txt
	{
	filedelete,%title%.txt
	}
fileappend,
(
%width%
%height%
),%title%.txt
FileSetAttrib,+H,%title%.txt
Win__GetDesktopPos(X, Y, W, H)
WinMove, A,, X, Y, W/2, H
}

Win__HalfRight()
{	
wingetactivestats,ActiveTitle,Width,Height,x,Y
winget,Title,ID,%ActiveTitle%
ifexist,%title%.txt
	{
	filedelete,%title%.txt
	}
fileappend,
(
%width%
%height%
),%title%.txt
FileSetAttrib,+H,%title%.txt
Win__GetDesktopPos(X, Y, W, H)
winMove, A,, X + W/2, Y, W/2, H
}

Win__FullSize()
{
wingetactivestats,ActiveTitle,Width,Height,x,Y
winget,Title,ID,%ActiveTitle%
ifexist,%title%.txt
	{
	filedelete,%title%.txt
	}
fileappend,
(
%width%
%height%
),%title%.txt
FileSetAttrib,+H,%title%.txt
Win__GetDesktopPos(X, Y, W, H)
WinMove, A,, X, Y, W, H
}


*~LButton::
 CoordMode, Mouse, Screen
 MouseGetPos, x, y, hwnd
 SendMessage, 0x84, 0, (x&0xFFFF) | (y&0xFFFF) << 16,, ahk_id %hwnd%
 RegExMatch("ERROR TRANSPARENT NOWHERE CLIENT CAPTION SYSMENU SIZE MENU HSCROLL VSCROLL MINBUTTON MAXBUTTON LEFT RIGHT TOP TOPLEFT TOPRIGHT BOTTOM BOTTOMLEFT BOTTOMRIGHT BORDER OBJECT CLOSE HELP", "(?:\w+\s+){" . ErrorLevel+2&0xFFFFFFFF . "}(?<AREA>\w+\b)", HT)
 if htarea!=CAPTION
	Return
 MouseGetPos,_x,_y
 While GetKeyState("LButton","P") && x=_x && y=_y ;Wait until user begins dragging
	MouseGetPos,_x,_y
 While GetKeyState("LButton","P") ;Show ToolTip while dragging
	{
	keywait,lbutton
	coordmode,mouse,screen
	MouseGetPos,Mouse_X,Mouse_Y
	if Mouse_X=0
		{
		Win__HalfLeft()
	return
		}
	Win__GetDesktopPos(X,Y,Width,Height)	
	Width-=5
	if (width < mouse_x)
		{
		Win__HalfRight()
	return
		}
	if mouse_y=0
		{
		Win__FullSize()
	return
		}
	WinGetActiveTitle,ActiveTitle
	winget,Title,ID,%ActiveTitle%
	ifexist,%title%.txt
		{
		filereadline,Originalwidth,%title%.txt,1
		filereadline,Originalheight,%title%.txt,2
		filedelete,%title%.txt
		WinGetActiveStats,ActiveTitle,total,CurrentHeight,p,p
		coordmode,mouse,relative
		MouseGetPos,given
		Part:= given / total
		Percent:= Part*100
		part2:= percent / 100
		part3:= part2*originalwidth
		coordmode,mouse,screen
		MouseGetPos,mouse_x
		Win__GetDesktopPos(X,Y,Width,Height) 
		final1:= width-mouse_x
		final2:= final1+part3
		final3:= width-final2
		test:=final3+originalwidth
		coordmode,mouse,screen
		MouseGetPos,mouse
		test1:=test-mouse
		mouse2:=mouse-final3
		if mouse2<23
			{
			final4:=final3-mouse2-2
			final3=%final4%
			}
		if mouse2=
			{
			tooltip,none
			final4:=final3-mouse2
			final3=%final4%
			}
		if test1<75
			{
			test2:=77-test1
			final4:=final3+test2
			final3=%final4%
			}		
		winmove,%ActiveTitle%,,%final3%,,%originalwidth%,%originalheight%
		return
		}
	}
Return

#right::Win__HalfRight()
#left::Win__HalfLeft()
#up::Win__FullSize()


gwarble
  • Members
  • 624 posts
  • Last active: Aug 12 2016 07:49 PM
  • Joined: 23 May 2009
yup, pretty close, i'm north of san francisco :)

so the second problem is seen when a maximized window is the set to WinHalfRight... so the window state is still in maximized mode, but the window takes up half the screen... which looks fine, until you drag it from there and it stays maximized and small, or maximized and in a weird position (depending on which version of your script)

thanks again
- gwarble

KooKsTeR
  • Members
  • 157 posts
  • Last active: Aug 21 2015 09:55 PM
  • Joined: 19 Feb 2010
Yeah i noticed that one about an hour ago, I guess to prevent that we will need a way to detect if the window is maximized, anyone know a way off the top of their head?

Ok heres the fix for that glitch:

#NoEnv

Win__GetDesktopPos(ByRef X, ByRef Y, ByRef W, ByRef H)
	{
	WinGetPos, TrayX, TrayY, TrayW, TrayH, ahk_class Shell_TrayWnd
	if (TrayW = A_ScreenWidth)
		{
		X := 0
		Y := TrayY ? 0 : TrayH
		W := A_ScreenWidth
		H := A_ScreenHeight - TrayH
		}
	else
		{
		X := TrayX ? 0 : TrayW
		Y := 0
		W := A_ScreenWidth - TrayW
		H := A_ScreenHeight
		}
	}

Win__HalfLeft()
{
wingetactivestats,ActiveTitle,Width,Height,x,Y
winget,ID#,ID,%ActiveTitle%
winget,test,MinMax,%activetitle%
if test=1
	{
	return
	}
ifexist,%ID#%.txt
	{
	goto,skipleft
	}
fileappend,
(
%width%
%height%
),%ID#%.txt
FileSetAttrib,+H,%title%.txt
skipleft:
Win__GetDesktopPos(X, Y, W, H)
WinMove, A,, X, Y, W/2, H
}

Win__HalfRight()
{	
wingetactivestats,ActiveTitle,Width,Height,x,Y
winget,ID#,ID,%ActiveTitle%
winget,test,MinMax,%activetitle%
if test=1
	{
	return
	}
ifexist,%ID#%.txt
	{
	goto,skipright
	}
fileappend,
(
%width%
%height%
),%ID#%.txt
FileSetAttrib,+H,%ID#%.txt
skipright:
Win__GetDesktopPos(X, Y, W, H)
winMove, A,, X + W/2, Y, W/2, H
}

Win__FullSize()
{
wingetactivestats,ActiveTitle,Width,Height,x,Y
winget,ID#,ID,%ActiveTitle%
ifexist,%ID#%.txt
	{
	goto,skipfull
	}
fileappend,
(
%width%
%height%
),%ID#%.txt
FileSetAttrib,+H,%ID#%.txt
skipfull:
Win__GetDesktopPos(X, Y, W, H)
WinMove, A,, X, Y, W, H
}


*~LButton::
 CoordMode, Mouse, Screen
 MouseGetPos, x, y, hwnd
 SendMessage, 0x84, 0, (x&0xFFFF) | (y&0xFFFF) << 16,, ahk_id %hwnd%
 RegExMatch("ERROR TRANSPARENT NOWHERE CLIENT CAPTION SYSMENU SIZE MENU HSCROLL VSCROLL MINBUTTON MAXBUTTON LEFT RIGHT TOP TOPLEFT TOPRIGHT BOTTOM BOTTOMLEFT BOTTOMRIGHT BORDER OBJECT CLOSE HELP", "(?:\w+\s+){" . ErrorLevel+2&0xFFFFFFFF . "}(?<AREA>\w+\b)", HT)
 if htarea!=CAPTION
	Return
 MouseGetPos,_x,_y
 While GetKeyState("LButton","P") && x=_x && y=_y ;Wait until user begins dragging
	MouseGetPos,_x,_y
 While GetKeyState("LButton","P") ;Show ToolTip while dragging
	{
	keywait,lbutton
	coordmode,mouse,screen
	MouseGetPos,Mouse_X,Mouse_Y
	if Mouse_X=0
		{
		Win__HalfLeft()
	return
		}
	Win__GetDesktopPos(X,Y,Width,Height)	
	Width-=5
	if (width < mouse_x)
		{
		Win__HalfRight()
	return
		}
	if mouse_y=0
		{
		Win__FullSize()
	return
		}
	WinGetActiveTitle,ActiveTitle
	winget,Title,ID,%ActiveTitle%
	ifexist,%title%.txt
		{
		filereadline,Originalwidth,%title%.txt,1
		filereadline,Originalheight,%title%.txt,2
		filedelete,%title%.txt
		WinGetActiveStats,ActiveTitle,total,CurrentHeight,p,p
		coordmode,mouse,relative
		MouseGetPos,given
		Part:= given / total
		Percent:= Part*100
		part2:= percent / 100
		part3:= part2*originalwidth
		coordmode,mouse,screen
		MouseGetPos,mouse_x
		Win__GetDesktopPos(X,Y,Width,Height) 
		final1:= width-mouse_x
		final2:= final1+part3
		final3:= width-final2
		test:=final3+originalwidth
		coordmode,mouse,screen
		MouseGetPos,mouse
		test1:=test-mouse
		mouse2:=mouse-final3
		if mouse2<23
			{
			final4:=final3-mouse2-2
			final3=%final4%
			}
		if mouse2=
			{
			tooltip,none
			final4:=final3-mouse2
			final3=%final4%
			}
		if test1<75
			{
			test2:=77-test1
			final4:=final3+test2
			final3=%final4%
			}		
		winmove,%ActiveTitle%,,%final3%,,%originalwidth%,%originalheight%
		return
		}
	}
Return

#right::Win__HalfRight()
#left::Win__HalfLeft()
#up::Win__FullSize()


KooKsTeR
  • Members
  • 157 posts
  • Last active: Aug 21 2015 09:55 PM
  • Joined: 19 Feb 2010
ignore this

KooKsTeR
  • Members
  • 157 posts
  • Last active: Aug 21 2015 09:55 PM
  • Joined: 19 Feb 2010
Alright I know I am posting alot, but this version currently works the best I dont know of any problems with it.
It has the following functions which are all working correctly as far as I know:
1)half/full max drag
2)half/full max quick keys
3)remember prior size
4)center according to where you were holding when going back to prior size
5)will not center on context/min/max/close buttons.

Features that will be implemented:
1)ensure clearing of stored data.

*This version voids all other versions*
#NoEnv

Win__GetDesktopPos(ByRef X, ByRef Y, ByRef W, ByRef H)
	{
	WinGetPos, TrayX, TrayY, TrayW, TrayH, ahk_class Shell_TrayWnd
	if (TrayW = A_ScreenWidth)
		{
		X := 0
		Y := TrayY ? 0 : TrayH
		W := A_ScreenWidth
		H := A_ScreenHeight - TrayH
		}
	else
		{
		X := TrayX ? 0 : TrayW
		Y := 0
		W := A_ScreenWidth - TrayW
		H := A_ScreenHeight
		}
	}

Win__HalfLeft()
{
wingetactivestats,ActiveTitle,Width,Height,x,Y
winget,ID#,ID,%ActiveTitle%
winget,test,MinMax,%activetitle%
if test=1
	{
	return
	}
ifexist,%ID#%.txt
	{
	goto,skipleft
	}
fileappend,
(
%width%
%height%
),%ID#%.txt
FileSetAttrib,+H,%title%.txt
skipleft:
Win__GetDesktopPos(X, Y, W, H)
WinMove, A,, X, Y, W/2, H
}

Win__HalfRight()
{	
wingetactivestats,ActiveTitle,Width,Height,x,Y
winget,ID#,ID,%ActiveTitle%
winget,test,MinMax,%activetitle%
if test=1
	{
	return
	}
ifexist,%ID#%.txt
	{
	goto,skipright
	}
fileappend,
(
%width%
%height%
),%ID#%.txt
FileSetAttrib,+H,%ID#%.txt
skipright:
Win__GetDesktopPos(X, Y, W, H)
winMove, A,, X + W/2, Y, W/2, H
}

Win__FullSize()
{
wingetactivestats,ActiveTitle,Width,Height,x,Y
winget,ID#,ID,%ActiveTitle%
ifexist,%ID#%.txt
	{
	goto,skipfull
	}
fileappend,
(
%width%
%height%
),%ID#%.txt
FileSetAttrib,+H,%ID#%.txt
skipfull:
Win__GetDesktopPos(X, Y, W, H)
WinMove, A,, X, Y, W, H
}


*~LButton::
 CoordMode, Mouse, Screen
 MouseGetPos, x, y, hwnd
 SendMessage, 0x84, 0, (x&0xFFFF) | (y&0xFFFF) << 16,, ahk_id %hwnd%
 RegExMatch("ERROR TRANSPARENT NOWHERE CLIENT CAPTION SYSMENU SIZE MENU HSCROLL VSCROLL MINBUTTON MAXBUTTON LEFT RIGHT TOP TOPLEFT TOPRIGHT BOTTOM BOTTOMLEFT BOTTOMRIGHT BORDER OBJECT CLOSE HELP", "(?:\w+\s+){" . ErrorLevel+2&0xFFFFFFFF . "}(?<AREA>\w+\b)", HT)
 if htarea!=CAPTION
	Return
 MouseGetPos,_x,_y
 While GetKeyState("LButton","P") && x=_x && y=_y
	MouseGetPos,_x,_y
 While GetKeyState("LButton","P")
	{
	keywait,lbutton
	coordmode,mouse,screen
	MouseGetPos,Mouse_X,Mouse_Y
	if Mouse_X=0
		{
		Win__HalfLeft()
	return
		}
	Win__GetDesktopPos(X,Y,Width,Height)	
	Width-=5
	if (width < mouse_x)
		{
		Win__HalfRight()
	return
		}
	if mouse_y=0
		{
		Win__FullSize()
	return
		}
	WinGetActiveTitle,ActiveTitle
	winget,Title,ID,%ActiveTitle%
	ifexist,%title%.txt
		{
		filereadline,Originalwidth,%title%.txt,1
		filereadline,Originalheight,%title%.txt,2
		filedelete,%title%.txt
		WinGetActiveStats,ActiveTitle,total,CurrentHeight,p,p
		coordmode,mouse,relative
		MouseGetPos,given
		Part:= given / total
		Percent1:= Part*100
		part2:= percent1 / 100
		part3:= part2*originalwidth
		coordmode,mouse,screen
		MouseGetPos,mouse_x
		Win__GetDesktopPos(X,Y,Width,Height) 
		final1:= width-mouse_x
		final2:= final1+part3
		final3:= width-final2
		test:=final3+originalwidth
		coordmode,mouse,screen
		MouseGetPos,mouse
		test1:=test-mouse
		mouse2:=mouse-final3
		mouse3:=23-mouse2
		if mouse2<23
			{
			final4:=final3-mouse3
			final3=%final4%
			}
		if test1<75
			{
			test2:=77-test1
			final4:=final3+test2
			final3=%final4%
			}		
		winmove,%ActiveTitle%,,%final3%,,%originalwidth%,%originalheight%
		return
		}
	}
Return

#right::Win__HalfRight()
#left::Win__HalfLeft()
#up::Win__FullSize()


KooKsTeR
  • Members
  • 157 posts
  • Last active: Aug 21 2015 09:55 PM
  • Joined: 19 Feb 2010
This version ensures the clearing of stored data.

This might be the last version unless a bug is found or if I feel like doing live previews of size changes.
#NoEnv
#Persistent

IfNotExist, Temp
	{
	FileCreateDir, Temp
	}

SetBatchLines, -1
Process, Priority,, High

Gui +LastFound
hWnd := WinExist()

DllCall( "RegisterShellHookWindow", UInt,hWnd )
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
OnMessage( MsgNum, "ShellMessage" )
Return

ShellMessage( wParam,lParam )
{
  Global ID
  If ( wParam = 2 ) {
   SetFormat, Integer, Hex
   ID := lParam + 0
   SetFormat, Integer, D
   SetTimer, MyRoutine, -1
  }
}

MyRoutine:
filedelete,Temp/%ID%.txt
Return

Win__GetDesktopPos(ByRef X, ByRef Y, ByRef W, ByRef H)
	{
	WinGetPos, TrayX, TrayY, TrayW, TrayH, ahk_class Shell_TrayWnd
	if (TrayW = A_ScreenWidth)
		{
		X := 0
		Y := TrayY ? 0 : TrayH
		W := A_ScreenWidth
		H := A_ScreenHeight - TrayH
		}
	else
		{
		X := TrayX ? 0 : TrayW
		Y := 0
		W := A_ScreenWidth - TrayW
		H := A_ScreenHeight
		}
	}

Win__HalfLeft()
{
wingetactivestats,ActiveTitle,Width,Height,x,Y
winget,ID#,ID,%ActiveTitle%
winget,test,MinMax,%activetitle%
if test=1
	{
	return
	}
ifexist,Temp\%ID#%.txt
	{
	goto,skipleft
	}
fileappend,
(
%width%
%height%
),Temp\%ID#%.txt
FileSetAttrib,+H,Temp\%title%.txt
skipleft:
Win__GetDesktopPos(X, Y, W, H)
WinMove, A,, X, Y, W/2, H
}

Win__HalfRight()
{	
wingetactivestats,ActiveTitle,Width,Height,x,Y
winget,ID#,ID,%ActiveTitle%
winget,test,MinMax,%activetitle%
if test=1
	{
	return
	}
ifexist,Temp\%ID#%.txt
	{
	goto,skipright
	}
fileappend,
(
%width%
%height%
),Temp\%ID#%.txt
FileSetAttrib,+H,Temp\%ID#%.txt
skipright:
Win__GetDesktopPos(X, Y, W, H)
winMove, A,, X + W/2, Y, W/2, H
}

Win__FullSize()
{
wingetactivestats,ActiveTitle,Width,Height,x,Y
winget,ID#,ID,%ActiveTitle%
ifexist,Temp\%ID#%.txt
	{
	goto,skipfull
	}
fileappend,
(
%width%
%height%
),Temp\%ID#%.txt
FileSetAttrib,+H,Temp\%ID#%.txt
skipfull:
Win__GetDesktopPos(X, Y, W, H)
WinMove, A,, X, Y, W, H
}


*~LButton::
 CoordMode, Mouse, Screen
 MouseGetPos, x, y, hwnd
 SendMessage, 0x84, 0, (x&0xFFFF) | (y&0xFFFF) << 16,, ahk_id %hwnd%
 RegExMatch("ERROR TRANSPARENT NOWHERE CLIENT CAPTION SYSMENU SIZE MENU HSCROLL VSCROLL MINBUTTON MAXBUTTON LEFT RIGHT TOP TOPLEFT TOPRIGHT BOTTOM BOTTOMLEFT BOTTOMRIGHT BORDER OBJECT CLOSE HELP", "(?:\w+\s+){" . ErrorLevel+2&0xFFFFFFFF . "}(?<AREA>\w+\b)", HT)
 if htarea!=CAPTION
	Return
 MouseGetPos,_x,_y
 While GetKeyState("LButton","P") && x=_x && y=_y
	MouseGetPos,_x,_y
 if GetKeyState("LButton","P")=1
	{
	keywait,lbutton
	coordmode,mouse,screen
	MouseGetPos,Mouse_X,Mouse_Y
	if Mouse_X=0
		{
		Win__HalfLeft()
	return
		}
	Win__GetDesktopPos(X,Y,Width,Height)	
	Width-=5
	if (width < mouse_x)
		{
		Win__HalfRight()
	return
		}
	if mouse_y=0
		{
		Win__FullSize()
	return
		}
	WinGetActiveTitle,ActiveTitle
	winget,Title,ID,%ActiveTitle%
	ifexist,Temp\%title%.txt
		{
		filereadline,Originalwidth,Temp\%title%.txt,1
		filereadline,Originalheight,Temp\%title%.txt,2
		filedelete,Temp\%title%.txt
		WinGetActiveStats,ActiveTitle,total,CurrentHeight,p,p
		coordmode,mouse,relative
		MouseGetPos,given
		Part:= given / total
		Percent1:= Part*100
		part2:= percent1 / 100
		part3:= part2*originalwidth
		coordmode,mouse,screen
		MouseGetPos,mouse_x
		Win__GetDesktopPos(X,Y,Width,Height) 
		final1:= width-mouse_x
		final2:= final1+part3
		final3:= width-final2
		test:=final3+originalwidth
		coordmode,mouse,screen
		MouseGetPos,mouse
		test1:=test-mouse
		mouse2:=mouse-final3
		mouse3:=23-mouse2
		if mouse2<23
			{
			final4:=final3-mouse3
			final3=%final4%
			}
		if test1<75
			{
			test2:=80-test1
			final4:=final3+test2
			final3=%final4%
			}		
		winmove,%ActiveTitle%,,%final3%,,%originalwidth%,%originalheight%
		return
		}
	}
Return

#right::Win__HalfRight()
#left::Win__HalfLeft()
#up::Win__FullSize()

~^s::
sleep 100
reload


gwarble
  • Members
  • 624 posts
  • Last active: Aug 12 2016 07:49 PM
  • Joined: 23 May 2009
nice work man

personally i would store the window size in RAM and skip the temporary file altogether... and then maybe restore all windows onExit

also, with multiple monitors dragging to the right monitor triggers the WinHalfRight... instead of width-5<Mouse_X should probably have width-5<Mouse_X<width

but then that brings up a whole new version for multiple monitors i guess...

- gwarble

gwarble
  • Members
  • 624 posts
  • Last active: Aug 12 2016 07:49 PM
  • Joined: 23 May 2009
oh yeah, one final thing, it would be cool if the resizing to saved dimensions was done at the start of dragging a window away from its HalfSide pinned position... instead of resizing the window at the completion of the drag

not sure how feasable or easy, but a little more intuitive if its the right size already when you drop it

thanks again
- gwarble

KooKsTeR
  • Members
  • 157 posts
  • Last active: Aug 21 2015 09:55 PM
  • Joined: 19 Feb 2010
Yeah I want to make it change sizes before you finish the dragging. I have an idea of how i might be able to pull this off but not sure yet.

And I probably wont be doing support for multiple monitors, just because I dont have that setup, so I cant really test it.

Well this is what I got when i threw it together real quick. I think I might have a better way of doing it, but it will be VERY complicated! It might add a whole other page of code.

#NoEnv
#Persistent

IfNotExist, Temp
	{
	FileCreateDir, Temp
	}

SetBatchLines, -1
Process, Priority,, High

Gui +LastFound
hWnd := WinExist()

DllCall( "RegisterShellHookWindow", UInt,hWnd )
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
OnMessage( MsgNum, "ShellMessage" )
Return

ShellMessage( wParam,lParam )
{
  Global ID
  If ( wParam = 2 ) {
   SetFormat, Integer, Hex
   ID := lParam + 0
   SetFormat, Integer, D
   SetTimer, MyRoutine, -1
  }
}

MyRoutine:
filedelete,Temp/%ID%.txt
Return

Win__GetDesktopPos(ByRef X, ByRef Y, ByRef W, ByRef H)
	{
	WinGetPos, TrayX, TrayY, TrayW, TrayH, ahk_class Shell_TrayWnd
	if (TrayW = A_ScreenWidth)
		{
		X := 0
		Y := TrayY ? 0 : TrayH
		W := A_ScreenWidth
		H := A_ScreenHeight - TrayH
		}
	else
		{
		X := TrayX ? 0 : TrayW
		Y := 0
		W := A_ScreenWidth - TrayW
		H := A_ScreenHeight
		}
	}

Win__HalfLeft()
{
wingetactivestats,ActiveTitle,Width,Height,x,Y
winget,ID#,ID,%ActiveTitle%
winget,test,MinMax,%activetitle%
if test=1
	{
	return
	}
ifexist,Temp\%ID#%.txt
	{
	goto,skipleft
	}
fileappend,
(
%width%
%height%
),Temp\%ID#%.txt
FileSetAttrib,+H,Temp\%title%.txt
skipleft:
Win__GetDesktopPos(X, Y, W, H)
WinMove, A,, X, Y, W/2, H
}

Win__HalfRight()
{	
wingetactivestats,ActiveTitle,Width,Height,x,Y
winget,ID#,ID,%ActiveTitle%
winget,test,MinMax,%activetitle%
if test=1
	{
	return
	}
ifexist,Temp\%ID#%.txt
	{
	goto,skipright
	}
fileappend,
(
%width%
%height%
),Temp\%ID#%.txt
FileSetAttrib,+H,Temp\%ID#%.txt
skipright:
Win__GetDesktopPos(X, Y, W, H)
winMove, A,, X + W/2, Y, W/2, H
}

Win__FullSize()
{
wingetactivestats,ActiveTitle,Width,Height,x,Y
winget,ID#,ID,%ActiveTitle%
ifexist,Temp\%ID#%.txt
	{
	goto,skipfull
	}
fileappend,
(
%width%
%height%
),Temp\%ID#%.txt
FileSetAttrib,+H,Temp\%ID#%.txt
skipfull:
Win__GetDesktopPos(X, Y, W, H)
WinMove, A,, X, Y, W, H
}


*~LButton::
 CoordMode, Mouse, Screen
 MouseGetPos, x, y, hwnd
 SendMessage, 0x84, 0, (x&0xFFFF) | (y&0xFFFF) << 16,, ahk_id %hwnd%
 RegExMatch("ERROR TRANSPARENT NOWHERE CLIENT CAPTION SYSMENU SIZE MENU HSCROLL VSCROLL MINBUTTON MAXBUTTON LEFT RIGHT TOP TOPLEFT TOPRIGHT BOTTOM BOTTOMLEFT BOTTOMRIGHT BORDER OBJECT CLOSE HELP", "(?:\w+\s+){" . ErrorLevel+2&0xFFFFFFFF . "}(?<AREA>\w+\b)", HT)
 if htarea!=CAPTION
	Return
 MouseGetPos,_x,_y
 While GetKeyState("LButton","P") && x=_x && y=_y
	MouseGetPos,_x,_y
 if GetKeyState("LButton","P")=1
{
restart:
sleep 50
coordmode,mouse,screen
MouseGetPos,Mouse_X,Mouse_Y
WinGetActiveStats,ActiveTitle,total,CurrentHeight,p,p
if Mouse_X=0
	{
	Win__GetDesktopPos(X, Y, W, H)
	WinMove,%ActiveTitle%,, X, Y, W/2, H
	}
Win__GetDesktopPos(X,Y,Width,Height)	
Width-=5
if (width < mouse_x)
	{
	Win__GetDesktopPos(X, Y, W, H)
	winMove,%ActiveTitle%,, X + W/2, Y, W/2, H
	}
if mouse_y=0
	{
	Win__GetDesktopPos(X, Y, W, H)
	WinMove,%ActiveTitle%,, X, Y, W, H
	}	
If (GetKeyState("LButton","P")=0)
	{
	coordmode,mouse,screen
	MouseGetPos,Mouse_X,Mouse_Y
	if Mouse_X=0
		{
		Win__HalfLeft()
		return
		}
	Win__GetDesktopPos(X,Y,Width,Height)	
	Width-=5
	if (width < mouse_x)
		{
		Win__HalfRight()
		return
		}
	if mouse_y=0
		{
		Win__FullSize()
		return
		}
	WinGetActiveTitle,ActiveTitle
	winget,Title,ID,%ActiveTitle%
	ifexist,Temp\%title%.txt
		{
		filereadline,Originalwidth,Temp\%title%.txt,1
		filereadline,Originalheight,Temp\%title%.txt,2
		filedelete,Temp\%title%.txt
		WinGetActiveStats,ActiveTitle,total,CurrentHeight,p,p
		coordmode,mouse,relative
		MouseGetPos,given
		Part:= given / total
		Percent1:= Part*100
		part2:= percent1 / 100
		part3:= part2*originalwidth
		coordmode,mouse,screen
		MouseGetPos,mouse_x
		Win__GetDesktopPos(X,Y,Width,Height) 
		final1:= width-mouse_x
		final2:= final1+part3
		final3:= width-final2
		test:=final3+originalwidth
		coordmode,mouse,screen
		MouseGetPos,mouse
		test1:=test-mouse
		mouse2:=mouse-final3
		mouse3:=23-mouse2
		if mouse2<23
			{
			final4:=final3-mouse3
			final3=%final4%
			}
		if test1<75
			{
			test2:=80-test1
			final4:=final3+test2
			final3=%final4%
			}		
		winmove,%ActiveTitle%,,%final3%,,%originalwidth%,%originalheight%
		return
		}
	}
goto,restart
}
Return

#right::Win__HalfRight()
#left::Win__HalfLeft()
#up::Win__FullSize()

~^s::
sleep 100
reload

Also the reason I didnt store it in the memory is because I dont know how to properly read from the memory. If you or anyone else does that would be great. I might post a question in the ask a question forum, but for the mean time I am happy with it.

KooKsTeR
  • Members
  • 157 posts
  • Last active: Aug 21 2015 09:55 PM
  • Joined: 19 Feb 2010
Fixed an error dealing with maximized windows.

#NoEnv
#Persistent
process,exist,autohotkey.exe
Win7=%errorlevel%

FileRemoveDir,Temp
FileCreateDir,Temp

SetBatchLines, -1
Process, Priority,, High

Gui +LastFound
hWnd := WinExist()

DllCall( "RegisterShellHookWindow", UInt,hWnd )
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
OnMessage( MsgNum, "ShellMessage" )
Return

ShellMessage( wParam,lParam )
{
  Global ID
  If ( wParam = 2 ) {
   SetFormat, Integer, Hex
   ID := lParam + 0
   SetFormat, Integer, D
   SetTimer, MyRoutine, -1
  }
}

MyRoutine:
filedelete,Temp/%ID%.txt
Return

Win__GetDesktopPos(ByRef X, ByRef Y, ByRef W, ByRef H)
	{
	WinGetPos, TrayX, TrayY, TrayW, TrayH, ahk_class Shell_TrayWnd
	if (TrayW = A_ScreenWidth)
		{
		X := 0
		Y := TrayY ? 0 : TrayH
		W := A_ScreenWidth
		H := A_ScreenHeight - TrayH
		}
	else
		{
		X := TrayX ? 0 : TrayW
		Y := 0
		W := A_ScreenWidth - TrayW
		H := A_ScreenHeight
		}
	}

Win__HalfLeft()
{
wingetactivestats,ActiveTitle,Width,Height,x,Y
winget,ID#,ID,%ActiveTitle%
ifexist,Temp\%ID#%.txt
	{
	goto,skipleft
	}
fileappend,
(
%width%
%height%
),Temp\%ID#%.txt
FileSetAttrib,+H,Temp\%title%.txt
skipleft:
Win__GetDesktopPos(X, Y, W, H)
WinMove, A,, X, Y, W/2, H
}

Win__HalfRight()
{	
wingetactivestats,ActiveTitle,Width,Height,x,Y
winget,ID#,ID,%ActiveTitle%
ifexist,Temp\%ID#%.txt
	{
	goto,skipright
	}
fileappend,
(
%width%
%height%
),Temp\%ID#%.txt
FileSetAttrib,+H,Temp\%ID#%.txt
skipright:
Win__GetDesktopPos(X, Y, W, H)
winMove, A,, X + W/2, Y, W/2, H
}

Win__FullSize()
{
wingetactivestats,ActiveTitle,Width,Height,x,Y
winget,ID#,ID,%ActiveTitle%
ifexist,Temp\%ID#%.txt
	{
	goto,skipfull
	}
fileappend,
(
%width%
%height%
),Temp\%ID#%.txt
FileSetAttrib,+H,Temp\%ID#%.txt
skipfull:
Win__GetDesktopPos(X, Y, W, H)
WinMove, A,, X, Y, W, H
}


*~LButton::
 CoordMode, Mouse, Screen
 MouseGetPos, x, y, hwnd
 SendMessage, 0x84, 0, (x&0xFFFF) | (y&0xFFFF) << 16,, ahk_id %hwnd%
 RegExMatch("ERROR TRANSPARENT NOWHERE CLIENT CAPTION SYSMENU SIZE MENU HSCROLL VSCROLL MINBUTTON MAXBUTTON LEFT RIGHT TOP TOPLEFT TOPRIGHT BOTTOM BOTTOMLEFT BOTTOMRIGHT BORDER OBJECT CLOSE HELP", "(?:\w+\s+){" . ErrorLevel+2&0xFFFFFFFF . "}(?<AREA>\w+\b)", HT)
 if htarea!=CAPTION
	Return
 MouseGetPos,_x,_y
 While GetKeyState("LButton","P") && x=_x && y=_y
	MouseGetPos,_x,_y
 if GetKeyState("LButton","P")=1
	{
	keywait,lbutton
	wingetactivestats,ActiveTitle,Width,Height,x,Y
	winget,test,MinMax,%activetitle%
	if test=1
		{
		return
		}
	coordmode,mouse,screen
	MouseGetPos,Mouse_X,Mouse_Y
	if Mouse_X=0
		{
		Win__HalfLeft()
		return
		}
	Win__GetDesktopPos(X,Y,Width,Height)	
	Width-=5
	if (width < mouse_x)
		{
		Win__HalfRight()
		return
		}
	if mouse_y=0
		{
		Win__FullSize()
		return
		}
	WinGetActiveTitle,ActiveTitle
	winget,Title,ID,%ActiveTitle%
	ifexist,Temp\%title%.txt
		{
		filereadline,Originalwidth,Temp\%title%.txt,1
		filereadline,Originalheight,Temp\%title%.txt,2
		filedelete,Temp\%title%.txt
		WinGetActiveStats,ActiveTitle,total,CurrentHeight,p,p
		coordmode,mouse,relative
		MouseGetPos,given
		Part:= given / total
		Percent1:= Part*100
		part2:= percent1 / 100
		part3:= part2*originalwidth
		coordmode,mouse,screen
		MouseGetPos,mouse_x
		Win__GetDesktopPos(X,Y,Width,Height) 
		final1:= width-mouse_x
		final2:= final1+part3
		final3:= width-final2
		test:=final3+originalwidth
		coordmode,mouse,screen
		MouseGetPos,mouse
		test1:=test-mouse
		mouse2:=mouse-final3
		mouse3:=23-mouse2
		if mouse2<23
			{
			final4:=final3-mouse3
			final3=%final4%
			}
		if test1<75
			{
			test2:=80-test1
			final4:=final3+test2
			final3=%final4%
			}		
		winmove,%ActiveTitle%,,%final3%,,%originalwidth%,%originalheight%
		return
		}
	}
Return

#right::Win__HalfRight()
#left::Win__HalfLeft()
#up::Win__FullSize()

Im also moving further development of this to the ask for help section.