AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Moving the active window from one monitor to the other

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
JonathanAquino



Joined: 22 Jul 2006
Posts: 4

PostPosted: Thu Sep 18, 2008 7:23 am    Post subject: Moving the active window from one monitor to the other Reply with quote

This script moves the active window from one monitor to the other. It is similar to JumpWin.exe, but that stopped working for me for some reason. UltraMon has similar functionality, but is a bit expensive.

The default hotkey is Ctrl+Alt+Q.

Based on Thalon's code at http://www.autohotkey.com/forum/topic19440.html

Code:

;Moves the active window from one monitor to the other. Similar to JumpWin.exe, but that stopped working for me for some reason.
;Based on Thalon's code at http://www.autohotkey.com/forum/topic19440.html  [Jon Aquino 2008-09-17]

leftMonitorWidth = 1400
leftMonitorHeight = 1050
rightMonitorWidth = 1920
rightMonitorHeight = 1200

^!q::    ;Default hotkey is Ctrl+Alt+Q
activeWindow := WinActive("A")
if activeWindow = 0
{
    return
}
WinGet, minMax, MinMax, ahk_id %activeWindow%
if minMax = 1
{
    WinRestore, ahk_id %activeWindow%
}
WinGetPos, x, y, width, height, ahk_id %activeWindow%
if x < 0
{
    xScale := rightMonitorWidth / leftMonitorWidth
    yScale := rightMonitorHeight / leftMonitorHeight
    x := leftMonitorWidth + x
    newX := x * xScale
    newY := y * yScale
    newWidth := width * xScale
    newHeight := height * yScale
}
else
{
    xScale := leftMonitorWidth / rightMonitorWidth
    yScale := leftMonitorHeight / rightMonitorHeight
    newX := x * xScale
    newY := y * yScale
    newWidth := width * xScale
    newHeight := height * yScale
    newX := newX - leftMonitorWidth
}
WinMove, ahk_id %activeWindow%, , %newX%, %newY%, %newWidth%, %newHeight%
if minMax = 1
{
    WinMaximize, ahk_id %activeWindow%
}
WinActivate ahk_id %activeWindow%   ;Needed - otherwise another window may overlap it
return
Back to top
View user's profile Send private message
ruespe



Joined: 17 Jun 2008
Posts: 138

PostPosted: Fri Sep 19, 2008 9:45 am    Post subject: Reply with quote

Good idea. With SysGet you can retrieve screen resolution and multi-monitor info, so there would be no need for fix resolutions.
_________________
Greetings
Rog
Back to top
View user's profile Send private message
Gertlex



Joined: 29 Oct 2006
Posts: 38
Location: A2 MI

PostPosted: Wed Oct 01, 2008 8:58 pm    Post subject: Reply with quote

Awesome.

Now I just need to get a second monitor Very Happy
Back to top
View user's profile Send private message AIM Address
JonathanAquino



Joined: 22 Jul 2006
Posts: 4

PostPosted: Sat Oct 10, 2009 5:49 am    Post subject: Reply with quote

This works nicely when assigned to pressing both mouse buttons at the same time. Kensington MouseWorks lets me assign this button combination to Ctrl+Alt+Q—perhaps it can be done purely with AutoHotkey as well.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group