AutoHotkey Community

It is currently May 27th, 2012, 5:04 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: Resizing window function
PostPosted: April 2nd, 2010, 2:51 am 
Offline

Joined: May 3rd, 2009, 6:37 pm
Posts: 67
I thought about this and I think it would be really useful If I could resize any window with my mouse wheel, For example:

Ctrl + wheel up = adds +1 height and width in all directions of the window.
Ctrl + wheel down = substracts -1 height and width in all directions of the window.

I know this is possible, but I can't find any tutorials on how to tell autohotkey to add.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 2nd, 2010, 3:36 am 
How about this:
Code:
^WheelUp:: ResizeWindow( 1 )
^WheelDown:: ResizeWindow( -1 )

ResizeWindow( z ) {
   hwnd := WinExist("A")
   WinGetPos, X, Y, W, H, ahk_id %hwnd%
   WinMove, ahk_id %hwnd%, , % X-z, % Y-z, % W+2*z, % H+2*z
}


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 2nd, 2010, 3:44 am 
Offline

Joined: May 3rd, 2009, 6:37 pm
Posts: 67
Thank you, I modded this a bit but it's sloppy as hell. Is it possible to smooth the transition?

Code:
^WheelDown:: ResizeWindow( 50 )
^WheelUp:: ResizeWindow( -50 )

ResizeWindow( z ) {
   hwnd := WinExist("A")
   WinGetPos, X, Y, W, H, ahk_id %hwnd%
   WinMove, ahk_id %hwnd%, , % X-z, % Y-z, % W+2*z, % H+2*z
}


Thanks


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 2nd, 2010, 4:15 am 
Offline

Joined: April 22nd, 2008, 7:13 pm
Posts: 82
Hi OrlandoRd

Off the top of my head I'd use the A_ScreenWidth and A_ScreenHeight variables. You could do something like:
Get X,Y pos of window
Get height and width of window

(for height only)
%A_screenheight% - Y Pos of window - height of window = (V)ertical space remaining
Amount to add to window = V*0.2

I guess reducing the window would need something more like
Amount to reduce the window = (Height of window)*0.2

_________________
Inventing problems that need solutions...

Open Communicator
MouseTrainer


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 8th, 2010, 9:41 pm 
Offline

Joined: May 3rd, 2009, 6:37 pm
Posts: 67
bamp


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 8th, 2010, 10:13 pm 
Offline

Joined: October 17th, 2009, 9:40 am
Posts: 2
bump


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 8th, 2010, 10:40 pm 
Online

Joined: April 8th, 2009, 7:49 pm
Posts: 6073
Location: San Diego, California
Code:
^WheelDown:: ResizeWindow( 10, 5 )
^WheelUp:: ResizeWindow( 10, -5 )

/*
^WheelDown:: ResizeWindow( 50, 1 )
^WheelUp:: ResizeWindow( 50, -1 )
*/


ResizeWindow( s, z )
{
   hwnd := WinExist("A")
   WinGetPos, X, Y, W, H, ahk_id %hwnd%

   loop, %s%
   {
   ;   sleep, 100
   
      WinMove, ahk_id %hwnd%, , % X-(z*a_index), % Y-(z*a_index)
   , % W+(2*z*a_index), % H+(2*z*a_index)
   }
}

esc::exitapp

 


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 1st, 2010, 1:43 pm 
Offline

Joined: June 20th, 2009, 8:55 pm
Posts: 19
Check out SetWinDelay, as well.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 1st, 2010, 4:09 pm 
Offline

Joined: May 3rd, 2009, 6:37 pm
Posts: 67
@AHKisthebest

Yup, that did it, runs as smooth as it can get. thanks


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot] and 77 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group