brotherS
Master of Good Ideas
Honorary Member

Posts: 2,105
To make a difference, be different.
|
 |
« on: September 20, 2005, 08:26:54 AM » |
|
Hi! I don't remember where exactly I found this great script, maybe it's even skrommel's code  It works perfectly, I just miss ONE feature. The script should not only move the window but the mouse cursor with it, to prevent that the window would move away from beneath the cursor. Thanks in advance!  [ copy or print] ;move active window around with Windows+l/r/up/down ; move active window xx pixels right #right::   wingetpos x, y,,, A  ; get coordinates of the active window   x += 30      ; add this distance to the x coordinate   winmove, A,,%x%, %y% ; make the active window use the new coordinates   return       ; finish ; move active window xx pixels left #left::   wingetpos x, y,,, A   x -= 30   winmove, A,,%x%, %y%   return ; move active window xx pixels up #Up::   wingetpos x, y,,, A   y -= 30   winmove, A,,%x%, %y%   return ; move active window xx pixels down #Down::   wingetpos x, y,,, A   y += 30   winmove, A,,%x%, %y%   return
|
|
|
|
« Last Edit: March 07, 2006, 02:37:09 AM by brotherS »
|
Logged
|
Thank you.
|
|
|
|
Carol Haynes
|
 |
« Reply #1 on: September 20, 2005, 10:00:14 AM » |
|
You use MouseGetPos and MouseMove in each secition to acheive your goal? You also need to add a condition to stop the window disappearing off the screen area too (unless that's what you want).
I have changed it to Control+Windows+arrow so that you don't lose access to the Windows key.
;move active window around with Ctrl+Windows+l/r/up/down ; move active window xx pixels right ^#right:: wingetpos x, y,,, A ; get coordinates of the active window x += 30 ; add this distance to the x coordinate mousegetpos, mx, my winmove, A,,%x%, %y% ; make the active window use the new coordinates mousemove, %mx%, %my% return ; finish
; move active window xx pixels left ^#left:: wingetpos x, y,,, A x -= 30 mousegetpos, mx, my winmove, A,,%x%, %y% mousemove, %mx%, %my% return
; move active window xx pixels up ^#Up:: wingetpos x, y,,, A y -= 30 mousegetpos, mx, my winmove, A,,%x%, %y% mousemove, %mx%, %my% return
; move active window xx pixels down ^#Down:: wingetpos x, y,,, A y += 30 mousegetpos, mx, my winmove, A,,%x%, %y% mousemove, %mx%, %my% return
|
|
|
|
« Last Edit: September 20, 2005, 10:17:31 AM by CarolHaynes »
|
Logged
|
|
|
|
brotherS
Master of Good Ideas
Honorary Member

Posts: 2,105
To make a difference, be different.
|
 |
« Reply #2 on: September 20, 2005, 10:38:15 AM » |
|
CarolHaynes: thanks!  It works perfectly, but is there a way to speed it up? I can't more around windows as fast as before, there's a noticeable delay when hitting a hotkey often (to move it to the other side of the screen) and sometimes the script 'swallows' one of the key presses then...
|
|
|
|
|
Logged
|
Thank you.
|
|
|
|
|
Carol Haynes
|
 |
« Reply #3 on: September 20, 2005, 10:53:05 AM » |
|
This version seems to be a bit quicker. But you may want to see if you could increase the step size the longer the key is held - that would really make it customizable  Skrommel - any idea how to do that? ;move active window around with ctrl+Windows+l/r/up/down ; move active window xx pixels right ^#right:: wingetpos x, y,,, A ; get coordinates of the active window x += 30 ; add this distance to the x coordinate mousegetpos, mx, my winmove, A,,%x%, %y% ; make the active window use the new coordinates mousemove, %mx%, %my%, 0 return ; finish ; move active window xx pixels left ^#left:: wingetpos x, y,,, A x -= 30 mousegetpos, mx, my winmove, A,,%x%, %y% mousemove, %mx%, %my%, 0 return ; move active window xx pixels up ^#Up:: wingetpos x, y,,, A y -= 30 mousegetpos, mx, my winmove, A,,%x%, %y% mousemove, %mx%, %my%, 0 return ; move active window xx pixels down ^#Down:: wingetpos x, y,,, A y += 30 mousegetpos, mx, my winmove, A,,%x%, %y% mousemove, %mx%, %my%, 0 return
|
|
|
|
|
Logged
|
|
|
|
brotherS
Master of Good Ideas
Honorary Member

Posts: 2,105
To make a difference, be different.
|
 |
« Reply #4 on: September 20, 2005, 11:26:25 AM » |
|
Right, that IS faster, nice!  Let's see if Skrommel has anything to add 
|
|
|
|
|
Logged
|
Thank you.
|
|
|
|
skrommel
|
 |
« Reply #5 on: September 20, 2005, 02:05:31 PM » |
|
 Very useful script if you have a multi monitor system! And there's actually a very clever MouseMove in CarolHaynes' version - using the changing relative position to move it back to where it was - I never would have thought of that! About increasing the move when the key is held down, I'd suggest using A_TickCount and SetTimer to check how long it's been since the last move - long time=decrease, short time=increase. I still have left to make a really useful script to move the mouse using the keyboard, so I wish you good luck! There's also plenty of tips to be found at the forums at http://www.autohotkey.com/forum. Skrommel
|
|
|
|
|
Logged
|
|
|
|
brotherS
Master of Good Ideas
Honorary Member

Posts: 2,105
To make a difference, be different.
|
 |
« Reply #6 on: September 20, 2005, 02:17:24 PM » |
|
Hi Skrommel  Did you write the original code? You are right about the AutoHotkey forum but I love the coding snack section of this site! I bet if there would be more pages like that AutoHotkey would get more attention... many seem to confuse it with an alternative to C++ and hate it 
|
|
|
|
|
Logged
|
Thank you.
|
|
|
|
skrommel
|
 |
« Reply #7 on: September 20, 2005, 02:53:08 PM » |
|
 No, not my code, but I've seen a few like it on AutoHotkey. And I couldn't agree more on the C note  . I once spent a few months making a mouse tool to scroll the screen in C. In AHK it took one evening! Skrommel
|
|
|
|
|
Logged
|
|
|
|
|