AutoHotkey Community

It is currently May 26th, 2012, 9:44 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: September 18th, 2008, 7:23 am 
Offline

Joined: July 22nd, 2006, 6:29 am
Posts: 5
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 19th, 2008, 9:45 am 
Offline

Joined: June 17th, 2008, 7:51 am
Posts: 243
Good idea. With SysGet you can retrieve screen resolution and multi-monitor info, so there would be no need for fix resolutions.

_________________
Greetings
Rog


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 1st, 2008, 8:58 pm 
Offline

Joined: October 29th, 2006, 4:09 am
Posts: 39
Location: A2 MI
Awesome.

Now I just need to get a second monitor :D


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 10th, 2009, 5:49 am 
Offline

Joined: July 22nd, 2006, 6:29 am
Posts: 5
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.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Stigg and 13 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