topbanner_forum
  *

avatar image

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

Login with username, password and session length
  • Tuesday March 19, 2024, 1:30 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: DONE: move around windows with keys + extra feature  (Read 13852 times)

brotherS

  • Master of Good Ideas
  • Honorary Member
  • Joined in 2005
  • **
  • Posts: 2,260
    • View Profile
    • Donate to Member
DONE: move around windows with keys + extra feature
« on: September 20, 2005, 08:26 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! :up:

;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 AM by brotherS »

Carol Haynes

  • Waffles for England (patent pending)
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 8,066
    • View Profile
    • Donate to Member
Re: IDEA - almost DONE: move around windows with keys + EXTRA FEATURE
« Reply #1 on: September 20, 2005, 10:00 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 AM by CarolHaynes »

brotherS

  • Master of Good Ideas
  • Honorary Member
  • Joined in 2005
  • **
  • Posts: 2,260
    • View Profile
    • Donate to Member
Re: IDEA - almost DONE: move around windows with keys + EXTRA FEATURE
« Reply #2 on: September 20, 2005, 10:38 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...

Carol Haynes

  • Waffles for England (patent pending)
  • Global Moderator
  • Joined in 2005
  • *****
  • Posts: 8,066
    • View Profile
    • Donate to Member
Re: IDEA - almost DONE: move around windows with keys + EXTRA FEATURE
« Reply #3 on: September 20, 2005, 10:53 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  :up:

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

brotherS

  • Master of Good Ideas
  • Honorary Member
  • Joined in 2005
  • **
  • Posts: 2,260
    • View Profile
    • Donate to Member
Re: IDEA - almost DONE: move around windows with keys + EXTRA FEATURE
« Reply #4 on: September 20, 2005, 11:26 AM »
Right, that IS faster, nice! :up:

Let's see if Skrommel has anything to add :)

skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • View Profile
    • 1 Hour Software by skrommel
    • Donate to Member
Re: IDEA - almost DONE: move around windows with keys + EXTRA FEATURE
« Reply #5 on: September 20, 2005, 02:05 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

brotherS

  • Master of Good Ideas
  • Honorary Member
  • Joined in 2005
  • **
  • Posts: 2,260
    • View Profile
    • Donate to Member
Re: IDEA - almost DONE: move around windows with keys + EXTRA FEATURE
« Reply #6 on: September 20, 2005, 02:17 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 :(


skrommel

  • Fastest code in the west
  • Developer
  • Joined in 2005
  • ***
  • Posts: 933
    • View Profile
    • 1 Hour Software by skrommel
    • Donate to Member
Re: IDEA - almost DONE: move around windows with keys + EXTRA FEATURE
« Reply #7 on: September 20, 2005, 02:53 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