topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Friday April 19, 2024, 12:55 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: IDEA: resize window from centre  (Read 6770 times)

SteveJohnSteele

  • Participant
  • Joined in 2009
  • *
  • default avatar
  • Posts: 9
    • View Profile
    • Donate to Member
IDEA: resize window from centre
« on: November 04, 2009, 04:06 PM »
Normally when you resize a window you grab the bottom+right corner and the top+left corner doesnt move.

My suggestion is ...
That the center of the window remains constant, but the window resizes around that center. All four corners moving out from the center.
- when holding down mouse + shift

OR optionally
The bottom corners moving out from centre (titlebar Y (up) position constant)
- when holding down mouse + ctrl

Of course this would also need to work on any edge.

hope you like.

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: IDEA: resize window from centre
« Reply #1 on: November 04, 2009, 08:33 PM »
Mouse drag might be a bit weird if you reposition the window while resizing.
I did this instead.  If you hold down the Left Control key while using the Mouse Wheel it should resize and center.  If you are going to resize by a large amount I recommend doing it the regular way at first, until you are close to the size you want, then hold down Left Control and move the mouse wheel up for larger and down for smaller.  It will resize the active window by increments and center it.

The only safety I have built in is it does nothing if the Desktop or Taskbar/Tray is active.  Don't want to mess with resizing those.  :)

To change to a different hotkey just change the script.  See AutoHotKey forum for compiler if you want to compile it to exe file.

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
LControl & WheelUp::
IfWinActive,ahk_class Progman
Return
IfWinActive,ahk_class Shell_TrayWnd
Return
WinGetPos,X,Y,Width,Height,A
Width := Round(Width * 1.1)
Height := Round(Height * 1.1)
If (Width > A_ScreenWidth)
  Width = A_ScreenWidth
If (Height > A_ScreenHeight)
  Height = A_ScreenHeight
WinGetTitle,Title,A
WinMove, %Title%,, (A_ScreenWidth/2)-(Width/2), (A_ScreenHeight/2)-(Height/2),%Width%,%Height%
Return

LControl & WheelDown::
IfWinActive,ahk_class Progman
Return
IfWinActive,ahk_class Shell_TrayWnd
Return
WinGetPos,X,Y,Width,Height,A
Width := Width - 20
Height := Height - 16
WinGetTitle,Title,A
WinMove, %Title%,, (A_ScreenWidth/2)-(Width/2), (A_ScreenHeight/2)-(Height/2),%Width%,%Height%
Return

SteveJohnSteele

  • Participant
  • Joined in 2009
  • *
  • default avatar
  • Posts: 9
    • View Profile
    • Donate to Member
Re: IDEA: resize window from centre
« Reply #2 on: November 04, 2009, 09:20 PM »
Many thanks  8)

Ive hacked your code a bit ...

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

LControl & WheelUp::
IfWinActive,ahk_class Progman
Return
IfWinActive,ahk_class Shell_TrayWnd
Return

WinGetPos,X,Y,Width,Height,A
WinGetTitle,Title,A

X := X-8
Y := Y
Width := Width+16
Height := Height+16

WinMove, %Title%,, X, Y,%Width%,%Height%
Return

LControl & WheelDown::
IfWinActive,ahk_class Progman
Return
IfWinActive,ahk_class Shell_TrayWnd
Return

WinGetPos,X,Y,Width,Height,A
WinGetTitle,Title,A

X := X+8
Y := Y
Width := Width-16
Height := Height-16

WinMove, %Title%,, X, Y,%Width%,%Height%
Return

this allows for the window to be positioned anywhere
also by not changing the Y the title bar stays still

vixay

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 140
  • ViXaY
    • View Profile
    • Donate to Member
Re: IDEA: resize window from centre
« Reply #3 on: November 04, 2009, 10:52 PM »
what you are looking for is NiftyWindows
Already done in AHK. I think you'll find it is very userful.
You can also search for WinManagement AHK script, or GridMove for some other window management programs
"Drunk on the Nectar of Life!" -me

CleverCat

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,164
    • View Profile
    • Donate to Member
Re: IDEA: resize window from centre
« Reply #4 on: November 05, 2009, 01:01 AM »
NiftyWindows is excellent as due to my disability I sometimes struggle to grab corner of window! Works a treat using just right click.. :Thmbsup:

lanux128

  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 6,277
    • View Profile
    • Donate to Member
Re: IDEA: resize window from centre
« Reply #5 on: November 05, 2009, 01:38 AM »
some time back i wrote a simple script called MouserSize for a forum member, nudone. you can find it here.

MilesAhead

  • Supporting Member
  • Joined in 2009
  • **
  • Posts: 7,736
    • View Profile
    • Donate to Member
Re: IDEA: resize window from centre
« Reply #6 on: November 05, 2009, 05:56 PM »
Ive hacked your code a bit ...
-SteveJohnSteele (November 04, 2009, 09:20 PM)

Nice hack.  I like it.  Doesn't jump around in an annoying fashion like my script. :)

btw for a "one shot" resize and center there's an exe rw for resize window that I have in a download:
http://www.favessoft.com/RunAndPlace.zip

it's a simple command line
rw [% width] [% height] Title   centers window with Title and sizes to % of work area

default with just Title specified is 50% width and height
Specifying one % sets both width and height the same
Specifying both you can set width and height individually.

Comes in handy mainly for batch files if you want to position a bunch of windows to specific places using rw and some of the other exe files in the zip.  But it doesn't have the bells and whistles of a mature window gizmo.  Just a quick and dirty. :)
« Last Edit: November 05, 2009, 06:04 PM by MilesAhead »