Features:
- Left and Right Snap, will also detect in between two monitors, Windows 7 doesn't!
- Maximize Snap
- Minimize Snap
- (New) Corner Snap
- (New) Half Screen Snap, just move the mouse while dragging a window in between the corner and the middle of the edge of the screen.
- Supports multiple monitors
Fixed:
- Should work with most irregular window gui's (IE Office 2008+)
- Should remember previous window size consistently
Known issues:
- Window hot-key's do nothing (I just haven't remade them)
- The Mouse loses grip of window on first unsnap (I don't know why it does this)
- Sometimes window isn't re-sized back when unsnapping (This may just be a timing issue)
Note:
- You need to have the windows setting "Show window contents while dragging" to be enabled.
- The latest version was built on ahk_l so it might not be backwards compatible.
Newest Version:
#Persistent
#InstallMouseHook
#InstallKeybdHook
detecthiddenwindows ,on
SetBatchLines, -1
setkeydelay,-1
SetMouseDelay,-1
SetWinDelay,-1
SetControlDelay,-1
Process, Priority,, High
Gui +LastFound
hWnd := WinExist()
DllCall( "RegisterShellHookWindow", UInt,hWnd )
MsgNum := DllCall( "RegisterWindowMessage", Str,"SHELLHOOK" )
OnMessage( MsgNum, "ShellMessage" )
Loop
{
WinGet,State,MinMax,a
if ( State = 1 )
{
Win__GetDesktopPos(x,y,w,h)
WinRestore,a
winmove,A,,%x%,%y%,%w%,%h%
}
sleep 100
}
Return
ShellMessage( wParam,lParam )
{
Global ID
If ( wParam = "2" )
{
SetFormat, Integer, Hex
hwnd := lParam + 0
SetFormat, Integer, D
SetTimer, Win_Closed, -1
}
}
Win_Closed:
If ( %hwnd% = "1" )
%hwnd% := "" , w%hwnd% := "" , h%hwnd% := "" , Area%hwnd% := ""
return
Win__GetDesktopPos(ByRef X, ByRef Y, ByRef W, ByRef H)
{
CoordMode , Mouse , Screen
MouseGetPos , X4 , Y4
SysGet , MonitorCount, MonitorCount
SysGet , MonitorPrimary, MonitorPrimary
Loop, %MonitorCount%
{
SysGet, MonitorName, MonitorName, %A_Index%
SysGet, Monitor, Monitor, %A_Index%
SysGet, MonitorWorkArea, MonitorWorkArea, %A_Index%
If (( X4 < MonitorWorkAreaRight ) && ( MonitorWorkAreaLeft < X4 )) or ( MonitorWorkAreaRight = X4 ) or ( MonitorWorkAreaLeft = X4 )
{
y := MonitorWorkAreaTop
x := MonitorWorkAreaLeft
W := MonitorWorkAreaRight - Monitorleft
H := MonitorWorkAreaBottom
Break
}
}
}
~LButton::
FullRestart:
OnMessage( MsgNum, "ShellMessage" )
sleep 100
WinGetActiveTitle,Title
RClick := 0
WinGet, Style, Style, A
WinGet, State, MinMax, A
if ( State = 1 )
{
Win__GetDesktopPos(x,y,w,h)
WinRestore,a
winmove,A,,%x%,%y%,%w%,%h%
}
restart:
CoordMode, Mouse, Screen
MouseGetPos, 1st_X, 1st_Y, hwnd
WinGetPos,WX1,WY1,WW1,WH1,A
SendMessage, 0x84, 0, (1st_X&0xFFFF) | (1st_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)
Loop
{
MoveBuffer := 10
sleep 5
MouseGetPos , 2nd_X , 2nd_Y
WinGetPos,WX2,WY2,WW2,WH2,A
If ((( MoveBuffer + 2nd_x ) < 1st_x ) or (( 2nd_x - MoveBuffer ) > 1st_x ) or (( MoveBuffer + 2nd_y ) < 1st_y ) or (( 2nd_y - MoveBuffer ) > 1st_y )) && (( WX2 != WX1 ) or ( WY2 != WY1 )) && ( WW1 = WW2 ) && ( WH1 = WH2 )
If ( WW1 = WW2 ) && ( WH1 = WH2 ) && (( WX1 != WX2 ) or ( WY1 != WY2 ))
break
If (GetKeyState( "LButton" , "P" )=0)
{
If ( %hwnd% = "1" ) && (( WX1 != WX2 ) or ( WY1 != WY2 )) && (( WW1 = WW2 ) && ( WH1 = WH2 ))
Preview_Resize(Area%hwnd%,1,hwnd,%hwnd%)
return
}
If (GetKeyState( "RButton" , "P" ))
{
RClick := 1
If ( %hwnd% = "1" )
{
%hwnd% := "" , w%hwnd% := "" , h%hwnd% := "" , Area%hwnd% := ""
keywait,Rbutton
goto,restart
}
}
}
WinGetPos,WX3,WY3,WW3,WH3,A
;-----------------------------------;
; UnSnapped by dragging ;
;-----------------------------------;
If ( %hwnd% = "1" )
{
w := w%hwnd% , h := h%hwnd% , percent := (( 1st_X - WX1 ) / WW1 ) * 100 , On := 0
part := ( w * percent ) / 100
WinGetPos,WX,WY,WW,WH,A
Coordmode,Mouse,Relative
MouseGetPos, mX, mY
if ( WX1 + mX < WX1 +( w / 2 )) && ( WX1 + mX < WX1 +( WW1 / 2 ))
x := WX , On := 1
else if ( WX1 + mX > WX1 + WW1 - ( w / 2 )) && ( WX1 + mX > WX1 + WW1 - ( WW1 / 2 ))
x := WX1 + WW1 - w , On := 1
else
x := WX1 + mX - ( w /2 ) , On := 1
Coordmode,Mouse,Screen
If ( On = 1 )
{
MouseGetPos, mX, mY
send,{lbutton up}
winmove,A,,%x%,,%w%,%h%
click down %mx%,%my%
}
}
;-----------------------------------;
WinGetPos,X3,Y3,,,A
While (GetKeyState( "LButton" , "P" ))
{
MouseGetPos,Mx,My,Win_hwnd
WinGetPos,WX,WY,,,A
sleep 10
MouseGetPos,Mx2,My2,Win_hwnd
WinGetPos,WX2,WY2,,,A
if (((( Mx > Mx2 + 20 ) or ( Mx + 20 < Mx2 )) && ( WX = WX2 )) or ((( My > My2 + 20 ) or ( My + 20 < My2 )) && ( WY = WY2 ))) && ( Area )
{
Gui,Submit
WinGetActiveTitle,Title1
WinGetActiveTitle,Title2
While (GetKeyState( "LButton" , "P" )) && ( Title1 = Title2 )
{
sleep 10
WinGetActiveTitle,Title2
}
GoTo,FullRestart
}
Win__GetDesktopPos(x,y,w,h)
Buffer := 10
TopLeftW := ( w / 3 ) - 20
TopMidW := w / 3
TopRightW := ( w / 3 ) - 20
TopLeftX := 20 + x
TopMidX := 20 + TopLeftW + x
TopRightX := 20 + TopLeftW + TopMidW + x
TopRightCornerX := 20 + TopRightW + TopMidW + TopLeftW + x
LeftH := h - 40
RightH := h - 40
LeftY := 20
RightY := 20
RightX := TopRightCornerX
BottomX := h - 20
If ( Mx <= x + 20 ) && ( Mx >= x ) && ( My <= 20 ) && ( My >= 0 )
Area := "Top_Left_Corner"
else If ( Mx <= TopLeftX + TopLeftW ) && ( Mx >= TopLeftX ) && ( My <= Buffer ) && ( My >= 0 )
Area := "Top_Left"
else If ( Mx <= TopMidX + TopMidW ) && ( Mx >= TopMidX ) && ( My <= Buffer ) && ( My >= 0 )
Area := "Top"
else If ( Mx <= TopRightX + TopRightW ) && ( Mx >= TopRightX ) && ( My <= Buffer ) && ( My >= 0 )
Area := "Top_Right"
else If ( Mx <= TopRightCornerX + 20 ) && ( Mx >= TopRightCornerX ) && ( My <= 20 ) && ( My >= 0 )
Area := "Top_Right_Corner"
else If ( Mx <= Buffer + x ) && ( Mx >= x ) && ( My >= 20 ) && ( My <= 20 + LeftH )
Area := "Left"
else If ( Mx >= ( w + x ) - Buffer ) && ( Mx <= w + x ) && ( My >= 20 ) && ( My <= 20 + LeftH )
Area := "Right"
else If ( Mx >= x ) && ( Mx <= 20 + x ) && ( My >= BottomX )
Area := "Bottom_Left_Corner"
else If ( Mx >= x + 20 ) && ( Mx <= x + ( w / 3 ) ) && ( My >= BottomX )
Area := "Bottom_Left"
else If ( Mx >= x + TopLeftW + 20 ) && ( Mx <= x + 20 + TopLeftW + TopMidW ) && ( My >= BottomX )
Area := "Bottom"
else If ( Mx >= x + 20 + TopLeftW + TopMidW ) && ( Mx <= x + 20 + TopLeftW + TopMidW + TopRightW ) && ( My >= BottomX )
Area := "Bottom_Right"
else If ( Mx >= x + 20 + TopLeftW + TopMidW + TopRightW ) && ( My >= BottomX )
Area := "Bottom_Right_Corner"
else
{
On := 0
Win__GetDesktopPos(x2,y2,w2,h2)
WinGetPos,X,Y,W,H,A
MouseGetPos,Mx,My
If (( Y + H ) > h ) ;Bottom
Area := "Border"
If ( x2 + w2 < X + W) ;Right
Area := "Border"
If ( x2 > X ) ;Left
Area := "Border"
If ( y2 > Y ) ;Top
Area := "Border"
If ( W > w2 ) ;Width
Area := "Border"
If ( H > h2 ) ;Height
Area := "Border"
If ( Area != "Border" )
Area := ""
else
gui,submit
}
If ( Area != PreviousArea ) && ( Area != "Border" ) && !((Style & 0x40000)=0)
Preview_Resize(Area,Null,Null,Null)
PreviousArea := Area
If GetKeyState( "RButton" , "P" )
{
PreviousArea := "" , RClick := 1
Gui, Submit
keywait,Rbutton
goto,restart
}
}
WinGetPos,WX,WY,WW,WH,A
If ( Area ) && ( Area != "Bottom" ) && !((Style & 0x40000)=0)
{
WinGetPos,,,W1,H1,A
Preview_Resize(area,1,hwnd,%hwnd%)
WinGetPos,,,W2,H2,A
If ( W1 != W2 ) or ( H1 != H2 )
w%hwnd% := WW , h%hwnd% := WH , %hwnd% := 1 , Area%hwnd% := Area
}
if getkeystate("RButton","P")
return
If ( Area = "Bottom" )
{
Win__GetDesktopPos(x2,y2,w2,h2)
WinGetPos,X,Y,W,H,A
MouseGetPos,Mx,My
y := Y - ((Y + H) - h2 )
WinMove,A,,%x%,%y%,%w%,%h%
WinMinimize,A
}
Area := ""
tooltip
return
Preview_Resize(area,Resize,hwnd,byref hwnd_var)
{
Gui, Submit
sleep 0
Win__GetDesktopPos(X,Y,W,H)
If ( Area = "Top" )
x := x , y := y , w := w , h := h
else If ( Area = "Top_Right" ) or ( Area = "Top_Left" )
x := x , y := y , W := w , h := h / 2
else If ( Area = "Top_Right_Corner" )
x := x + ( w / 2 ) , w := w / 2 , h := h / 2
else If ( Area = "Right" )
x := x + ( w / 2 ) , y := y , w := w / 2 , h := h
else If ( Area = "Left" )
x := x , y := y , w := w / 2 , h := h
else If ( Area = "Top_Left_Corner" )
x := x , y := y , w := w / 2 , h := h / 2
else If ( Area = "Bottom_Left_Corner" )
x := x , y := h / 2 , W := w / 2 , h := h / 2
else If ( Area = "Bottom_Right_Corner" )
x := x + (w / 2 ) , y := h / 2 , W := w / 2 , h := h / 2
else If ( Area = "Bottom_Right" ) or ( Area = "Bottom_Left" )
x := x , y := h / 2 , W := w , h := h / 2
else If ( Area = "" )
x := 0 , y := 0 , w := 0 , h := 0
If ( Area = "Border" )
{
Win__GetDesktopPos(x2,y2,w2,h2)
WinGetPos,X,Y,W,H,A
MouseGetPos,Mx,My
If (( Y + H ) > h2 ) ;Bottom
y := Y - ((Y + H) - h2 ) , On := 1
If ( x2 + w2 < X + W) ;Right
x := x2 + w2 - W , On := 1
If ( x2 > X ) ;Left
x := x2 , On := 1
If ( y2 > Y ) ;Top
y := y2 , On := 1
If ( W > w2 ) ;Width
w := w2 , On := 1
If ( H > h2 ) ;Height
h := h2 , On := 1
}
x:=round(x) , y:=round(y) , w:=round(w) , h:=round(h)
If ( Area ) && !( Resize ) && ( Area != "Border" ) && ( Area != "Bottom" )
{
Gui, +AlwaysOnTop - Disabled +LastFound -sysmenu + ToolWindow +border
Gui, Show, w0 h0 NA
WinSet, Transparent, 85, %A_ScriptName%
WinSet, Region, W%w% H%h% R 0-0 , %A_ScriptName%
Gui, -Caption
Gui, Show, x%x% y%y% w%w% h%h% NA
}
If (( Resize = 1 ) && ( Area != "Bottom" )) or (( Area = "Border" ) && ( On = 1 ))
{
hwnd_var := 1
WinMove,A,,%x%,%y%,%w%,%h%
}
}Old Version:
#Persistent
detecthiddenwindows ,on
;---------------------------detects closing windows / clears old data
SetMouseDelay, -1
SetKeyDelay, -1
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:
if %ID%check=1
{
%ID%check=
%ID%width=
%ID%height=
%ID%X=
%ID%y=
%ID%x=
%ID%x_Original=
%ID%y_Original=
}
Return
;--------------------------------------------handles Preview
Win__SplashSet()
{
splashimage,shade2243324.jpg,hide b2
WinSet, Transparent, 85, %A_ScriptName%
x+=3
y+=3
w-=6
h-=6
}
;--------------------------handles checking/storing window information
Win__GetIDInformation(ByRef ID, ByRef Width, ByRef Height, ByRef X, ByRef Y)
{
WinGetActiveStats,Title,Width,Height,X,Y
winget,ID,ID,%Title%
check:=%id%check
if check=1
{
goto,skip
}
skip:
sleep 5
}
;-----------------------------------------handles desktop variables
Win__GetDesktopPos(ByRef X, ByRef Y, ByRef W, ByRef H)
{
CoordMode , Mouse , Screen
MouseGetPos , X4 , Y4
SysGet , MonitorCount, MonitorCount
SysGet , MonitorPrimary, MonitorPrimary
Loop, %MonitorCount%
{
SysGet, MonitorName, MonitorName, %A_Index%
SysGet, Monitor, Monitor, %A_Index%
SysGet, MonitorWorkArea, MonitorWorkArea, %A_Index%
If (( X4 < MonitorWorkAreaRight ) && ( MonitorWorkAreaLeft < X4 )) or ( MonitorWorkAreaRight = X4 ) or ( MonitorWorkAreaLeft = X4 )
{
y := MonitorWorkAreaTop
x := MonitorWorkAreaLeft
W := MonitorWorkAreaRight - Monitorleft
H := MonitorWorkAreaBottom
Break
}
}
}
;----------------------------------------handles left half maximize
Win__HalfLeft()
{
WinGetActiveStats,Title,Width,Height,X,Y
winget,ID,ID,%Title%
check:=%id%check
if check=1
{
goto,skipsave1
}
%ID%check=1
%ID%Width=%width%
%ID%Height=%height%
%ID%x=%x%
%ID%y=%y%
ID=
skipsave1:
Win__GetDesktopPos(X, Y, W, H)
WinMove, A,, X, Y, W/2, H
return
}
;----------------------------------------handles right half maximize
Win__HalfRight()
{
WinGetActiveStats,Title,Width,Height,X,Y
winget,ID,ID,%Title%
check:=%id%check
if check=1
{
goto,skipsave2
}
%ID%check=1
%ID%Width=%width%
%ID%Height=%height%
%ID%x=%x%
%ID%y=%y%
ID=
skipsave2:
Win__GetDesktopPos(X, Y, W, H)
winMove, A,, X + W/2, Y, W/2, H
return
}
;----------------------------------------handles full maximize
Win__FullSize()
{
WinGetActiveStats,Title,Width,Height,X,Y
winget,ID,ID,%Title%
check:=%id%check
if check=1
{
goto,skipsave3
}
%ID%check=1
%ID%Width=%width%
%ID%Height=%height%
%ID%x=%x%
%ID%y=%y%
ID=
skipsave3:
Win__GetDesktopPos(X, Y, W, H)
WinMove, A,, X, Y, W, H
return
}
;-----------------------detects when window is being dragged
~LButton::
sleep 50
WinGet, Style, Style, A
If (Style & 0x40000)=0
return
WinGetActiveStats ,void,void,void,WX1,WY1
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 = "TOP" )
{
WinGetActiveStats,Title,Width,Height,X,Y
winget,ID,ID,%Title%
check:=%id%check
if check=1
{
goto,skiptop
}
%ID%check=1
%ID%Width=%width%
%ID%Height=%height%
%ID%x=%x%
%ID%y=%y%
skiptop:
loop
{
sleep 5
coordmode,mouse,screen
MouseGetPos,Mouse_X,Mouse_Y
Win__GetDesktopPos(X, Y, W, H)
if ( Mouse_Y = Y )
{
Win__GetDesktopPos(X, Y, W, H)
Win__SplashSet()
wingetactivestats,Title,W,H2,x,Y
height:=h-h2-y
winmove,%A_ScriptName%,,X,Y+H2,W,height
SplashImage, Show, b2,,, SplashImage
loop
{
sleep 5
coordmode,mouse,screen
MouseGetPos,Mouse_X,Mouse_Y
if ( Mouse_Y > Y )
{
splashimage,off
goto,skiptop
}
If (GetKeyState("LButton","P")=0)
{
splashimage,off
Win__GetDesktopPos(X, Y, W, H)
winMove,A,,,Y,, H
return
}
}
}
If (GetKeyState("LButton","P")=0)
{
%ID%check=
%ID%Width=
%ID%Height=
%ID%x=
%ID%y=
%ID%Position=
return
}
}
}
if ( htarea = "BOTTOM" )
{
WinGetActiveStats,Title,Width,Height,X,Y
winget,ID,ID,%Title%
check:=%id%check
if check=1
{
goto,skipbottom
}
%ID%check=1
%ID%Width=%width%
%ID%Height=%height%
%ID%x=%x%
%ID%y=%y%
skipbottom:
loop
{
sleep 5
coordmode,mouse,screen
MouseGetPos,Mouse_X,Mouse_Y
Win__GetDesktopPos(X, Y, W, H)
check:=H-mouse_y-1
if (check<3)
{
Win__GetDesktopPos(X, Y, W, H)
Win__SplashSet()
wingetactivestats,Title,W,H,x,Y
winmove,%A_ScriptName%,,X,0,W,Y
SplashImage, Show, b2,,, SplashImage
loop
{
sleep 5
coordmode,mouse,screen
MouseGetPos,Mouse_X,Mouse_Y
Win__GetDesktopPos(X, Y, W, H)
check:=H-mouse_y-1
if (check>3)
{
splashimage,off
goto,skipbottom
}
If (GetKeyState("LButton","P")=0)
{
splashimage,off
Win__GetDesktopPos(X, Y, W, H)
winMove,A,,,0,, H
return
}
}
}
If (GetKeyState("LButton","P")=0)
{
%ID%check=
%ID%Width=
%ID%Height=
%ID%x=
%ID%y=
%ID%Position=
return
}
}
}
if ( htarea != "CAPTION" ) && ( htarea != "CLIENT" )
{
Return
}
MouseGetPos,_x,_y
Win__GetIDInformation(ID,z,z,x6,y6)
%ID%x_Original=%x6%
%ID%y_Original=%y6%
While GetKeyState("LButton","P") && x=_x && y=_y
{
start:
sleep 5
wingetactivestats,ActiveTitle,Width,Height,x,Y
winget,test,MinMax,%activetitle%
if test=1
{
return
}
CoordMode , Mouse, Screen
MouseGetPos , Mouse_X ,Mouse_Y
Win__GetDesktopPos(X,Y,Width,Height)
WinGetActiveStats ,void,void,void,WX2,WY2
If ( WX1 != WX2 ) or ( WY1 != WY2 )
if ( Mouse_X < X + 20 )
{
Win__GetDesktopPos(X, Y, W, H)
Win__SplashSet()
winmove,%A_ScriptName%,,x,y,w/2,h
SplashImage, Show, b2,,, SplashImage
loop
{
sleep 5
MouseGetPos,Mouse_X,Mouse_Y
;--------------------------------- Snap Left -----------------------------------
If (GetKeyState("LButton","P")=0)
{
Win__GetIDInformation(ID,Width,Height,x,y)
%ID%check=1
%ID%Width=%width%
%ID%Height=%height%
%ID%X=%X%
%ID%Y=%Y%
%ID%Position=L
ID=
splashimage,off
Win__GetDesktopPos(X, Y, W, H)
WinMove, A,, X, Y, W/2, H
return
}
;-------------------------------------------------------------------------------
If ( Mouse_X != 0 )
{
if ( Mouse_X > X + 20 )
{
splashimage,off
goto,start
}
if ( Mouse_X < X )
{
splashimage,off
goto,start
}
}
}
}
Win__GetDesktopPos(X,Y,Width,Height)
Width := width + X - 20
WinGetActiveStats ,void,void,void,WX2,WY2
If ( WX1 != WX2 ) or ( WY1 != WY2 )
if (width < mouse_x)
{
Win__GetDesktopPos(X, Y, W, H)
Win__SplashSet()
winmove,%A_ScriptName%,, X + W/2, Y, W/2, H
SplashImage, Show, b2,,, SplashImage
loop
{
sleep 5
MouseGetPos,Mouse_X,Mouse_Y
If (GetKeyState("LButton","P")=0)
{
Win__GetIDInformation(ID,Width,Height,x,y)
%ID%check=1
%ID%Width=%width%
%ID%Height=%height%
%ID%X=%X%
%ID%Position=R
ID=
splashimage,off
Win__GetDesktopPos(X, Y, W, H)
winMove, A,, X + W/2, Y, W/2, H
return
}
Win__GetDesktopPos(X,Y,Width,Height)
Width := width + X - 20
if (width > mouse_x)
{
splashimage,off
goto,start
}
}
}
WinGetActiveStats ,void,void,void,WX2,WY2
If ( WX1 != WX2 ) or ( WY1 != WY2 )
if mouse_y=0
{
Win__GetDesktopPos(X, Y, W, H)
Win__SplashSet()
winmove,%A_ScriptName%,,X, Y, W, H
SplashImage, Show, b2,,, SplashImage
loop
{
sleep 5
MouseGetPos,Mouse_X,Mouse_Y
If (GetKeyState("LButton","P")=0)
{
Win__GetIDInformation(ID,Width,Height,x,y)
%ID%check=1
%ID%Width=%width%
%ID%Height=%height%
%ID%X=%X%
%ID%Position=T
ID=
splashimage,off
Win__GetDesktopPos(X, Y, W, H)
winMove, A,, X, Y, W, H
return
}
if mouse_y>3
{
splashimage,off
goto,start
}
}
}
WinGetActiveStats,Title,Width,Height,X,Y
winget,ID,ID,%Title%
check:=%id%check
WinGetActiveStats ,void,void,void,WX2,WY2
IF ( htarea = "CAPTION" ) or ( ( htarea = "CLIENT" )&&(( WX1 != WX2 ) or ( WY1 != WY2 )))
if check=1
{
WinGetActiveStats,Current_Title,Current_Width,Current_Height,Current_X,Y
Win__GetDesktopPos(X,Y,Width,Height)
MouseGetPos,Mouse_Screen
winget,ID,ID,%current_Title%
Original_width:=%ID%Width
Original_height:=%ID%height
%ID%check=
%ID%Width=
%ID%height=
%ID%Position=
%ID%y=
%ID%x=
coordmode,mouse,relative
MouseGetPos,Mouse_Window
check:=current_width/2
if (mouse_window<check)
{
;(left side)
check:=original_width/2
if (mouse_window<check)
{
if (mouse_window>original_width-75)
{
;(Center the window left)
x:=mouse_screen-(original_width/2)
}
else
{
;(align left side)
x:=current_x
}
goto,end
}
}
check:=current_x+Current_width-Original_width+(original_width/2)
if (check<mouse_screen)
{
;(align right side)
x:=current_x+Current_width-Original_width
goto,end
}
if (Mouse_Window<Current_width-75)
{
;(center the window right)
x:=mouse_screen-(original_width/2)
goto,end
}
end:
if ( htarea != "CLIENT" )
{
winmove,%Current_Title%,,%x%,,%original_width%,%original_height%
ID:="" , x:=""
}
goto,start
}
If (GetKeyState("LButton","P")=0)
{
if ( htarea = "CLIENT" )
{
winmove,%Current_Title%,,%x%,,%original_width%,%original_height%
ID:="" , x:=""
}
return
}
goto,start
}
Return
;--------------------------------------Shortcut keys----------------------------------------------
#right::
WinGetActiveStats ,Title,Width,Height,X,Y
winget ,ID,ID,%Title%
Check := %id%Position
if ( Check = "T" ) or ( Check = "L" )
{
WinGetActiveStats,Current_Title,Current_Width,Current_Height,Current_X,Y
Win__GetDesktopPos(X,Y,Width,Height)
MouseGetPos,Mouse_Screen
winget,ID,ID,%current_Title%
Original_width:=%ID%Width
Original_height:=%ID%height
Original_X:=%ID%X_Original
Original_Y:=%ID%y_Original
%ID%check=
%ID%Width=
%ID%height=
%ID%y=
%ID%x=
%ID%x_Original=
%ID%y_Original=
%ID%Position=
winmove,%Current_Title%,,%Original_X%,%Original_Y%,%original_width%,%original_height%
ID=
x=
return
}
WinGetActiveStats , Title,Width,Height,X,Y
WinGet ,ID,ID,%Title%
Check := %id%check
if ( Check != 1 )
{
%ID%check=1
%ID%Width=%width%
%ID%Height=%height%
%ID%x=%x%
%ID%y=%y%
%ID%x_Original=%x%
%ID%y_Original=%y%
%ID%Position=R
}
Win__HalfRight()
Return
#left::
WinGetActiveStats ,Title,Width,Height,X,Y
winget ,ID,ID,%Title%
Check := %id%Position
if ( Check = "T" ) or ( Check = "R" )
{
WinGetActiveStats,Current_Title,Current_Width,Current_Height,Current_X,Y
Win__GetDesktopPos(X,Y,Width,Height)
MouseGetPos,Mouse_Screen
winget,ID,ID,%current_Title%
Original_width:=%ID%Width
Original_height:=%ID%height
Original_X:=%ID%X_Original
Original_Y:=%ID%y_Original
%ID%check=
%ID%Width=
%ID%height=
%ID%y=
%ID%x=
%ID%x_Original=
%ID%y_Original=
%ID%Position=
winmove,%Current_Title%,,%Original_X%,%Original_Y%,%original_width%,%original_height%
ID=
x=
return
}
WinGetActiveStats , Title,Width,Height,X,Y
WinGet ,ID,ID,%Title%
Check := %id%check
if ( Check != 1 )
{
%ID%check=1
%ID%Width=%width%
%ID%Height=%height%
%ID%x=%x%
%ID%y=%y%
%ID%x_Original=%x%
%ID%y_Original=%y%
%ID%Position=L
}
Win__HalfLeft()
Return
#up::
WinGetActiveStats , Title,Width,Height,X,Y
WinGet ,ID,ID,%Title%
Check := %id%check
if ( Check != 1 )
{
%ID%check=1
%ID%Width=%width%
%ID%Height=%height%
%ID%x=%x%
%ID%y=%y%
%ID%x_Original=%x%
%ID%y_Original=%y%
%ID%Position=T
}
Win__FullSize()
Return
#Down::
WinGetActiveStats ,Title,Width,Height,X,Y
winget ,ID,ID,%Title%
Check := %id%Position
if ( Check = "T" ) or ( Check = "R" ) or ( Check = "L" )
{
WinGetActiveStats,Current_Title,Current_Width,Current_Height,Current_X,Y
Win__GetDesktopPos(X,Y,Width,Height)
MouseGetPos,Mouse_Screen
winget,ID,ID,%current_Title%
Original_width:=%ID%Width
Original_height:=%ID%height
Original_X:=%ID%X_Original
Original_Y:=%ID%y_Original
%ID%check=
%ID%Width=
%ID%height=
%ID%y=
%ID%x=
%ID%x_Original=
%ID%y_Original=
%ID%Position=
winmove,%Current_Title%,,%Original_X%,%Original_Y%,%original_width%,%original_height%
ID=
x=
return
}
WinMinimize, ALast Updated:
November 19, 2011 11:41PM,
Fixed a glitched caused by fixing a previous glitch.
November 19, 2011 11:31PM,
Fixed it so it will work with office 2007 and other similar formatted windows.
Fixed it so it will not move/resize windows that are marked as windows that should not be.
June 8, 2011 4:28PM,
Made it so win key shortcuts will revert it back to its original size and position if you do a different hotkey from where the window is located.
I am having a glitch where it will not work properly the first time, but after that there is no problem.




