 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
keybored
Joined: 18 Jun 2006 Posts: 89 Location: Phoenix, AZ
|
Posted: Tue Mar 13, 2007 2:25 am Post subject: Move active window over for dual monitors |
|
|
This was written so I could move the active window to the other monitor regardless of what monitor it was on (for dual monitor setup).
There is a bug regarding Maximized windows. They move over 2 consecutive times.
I've compensated with +10 to the virtual width of the monitor. This causes the window not to line up after moving.
Also if others could test this on their dual monitor systems I'd like to know the results.
This actually is useful with a single monitor because you can temporarily move a window blocking your view.
| Code: | !`::
SysGet, sw, 78 ; gets the monitors virtual width
w := sw+10
WinGetPos, wx1, wy1, wd1, ht1, A
If (wx1 < 512)
{
WinMove, A, , wx1+(w/2), wy1
}
Else,
{
WinMove, A, , wx1-(w/2), wy1
}
return |
Last edited by keybored on Sat Mar 17, 2007 2:02 am; edited 1 time in total |
|
| Back to top |
|
 |
Stevie
Joined: 17 Aug 2006 Posts: 34
|
Posted: Fri Mar 16, 2007 12:43 am Post subject: |
|
|
id like to give you feedback but the script doesnt work.
---------------------------
dualmon.ahk
---------------------------
Error at line 6.
Line Text: If, (wx1 < 512)
Error: This line does not contain a recognized action.
The program will exit.
---------------------------
OK
--------------------------- |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6772 Location: Pacific Northwest, US
|
Posted: Fri Mar 16, 2007 12:51 am Post subject: |
|
|
It works great for me, except that the vertical position is referenced to the top of the virtual desktop area, which is bigger than my monitors (since the are not aligned vertically or horizontally)
I wonder how this will work on my six screen computer... I'll have to try that later. _________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6772 Location: Pacific Northwest, US
|
Posted: Fri Mar 16, 2007 12:52 am Post subject: |
|
|
| Stevie wrote: | id like to give you feedback but the script doesnt work.
|
What version of AHK do you have installed? _________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
Stevie
Joined: 17 Aug 2006 Posts: 34
|
Posted: Fri Mar 16, 2007 1:10 am Post subject: |
|
|
the latest, maybe im doing something wrong?
i have been inactive in ahk for a while.
what i did was copying the text into a file called dualmon.ahk and run it. |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6772 Location: Pacific Northwest, US
|
Posted: Fri Mar 16, 2007 3:22 am Post subject: |
|
|
try removing the comma from the bad If statement?
can you post the code from your file? _________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
Stevie
Joined: 17 Aug 2006 Posts: 34
|
Posted: Fri Mar 16, 2007 3:43 am Post subject: |
|
|
haha lol, yeah, the comma was the problem, doh. works now
okay here my feedback:
the script seems to work well, the only problem i encountered you can see on the screenshot here:
http://img106.imageshack.us/my.php?image=20070316035012pz3.jpg
its not maximized and doesnt really fit on the screen.[/img] |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6772 Location: Pacific Northwest, US
|
Posted: Fri Mar 16, 2007 5:13 am Post subject: Re: Move active window over for dual monitors |
|
|
This is expected, per the OP
| keybored wrote: |
There is a bug regarding Maximized windows. They move over 2 consecutive times.
I've compensated with +10 to the virtual width of the monitor. This causes the window not to line up after moving.
|
_________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
Stevie
Joined: 17 Aug 2006 Posts: 34
|
Posted: Fri Mar 16, 2007 12:22 pm Post subject: |
|
|
| ah silly me, i didnt read correctly, doh |
|
| Back to top |
|
 |
keybored
Joined: 18 Jun 2006 Posts: 89 Location: Phoenix, AZ
|
Posted: Sat Mar 17, 2007 2:06 am Post subject: 6 monitors And AHK sounds like fun! |
|
|
Hey thanks for mentioning the if statement, I fixed it.
Wow engunneer you have six monitors! Can I play?
I don't actually have dual monitors at home. At work I have a couple dual monitor setups, but no time to enjoy AHK. I might make progress on this in the next week or two.
So I could probably adjust the virtual width or just add up the dimensions of the monitors. Hmmmm any other ideas? |
|
| Back to top |
|
 |
engunneer
Joined: 30 Aug 2005 Posts: 6772 Location: Pacific Northwest, US
|
Posted: Sat Mar 17, 2007 4:13 am Post subject: |
|
|
i am in charge of a computer in work - basic old IBM laptop, except the external monitor is a 42" lcd HDTV, and it has the "sidecar" from digitaltigers.com, with 4 more 15" HP LCDs. we use it to display status updates of our projects at work, and it's an ahk script that takes screenshots from the database and shows 5 splashimages on the external screens.
not bad for about $3600 + the laptop _________________
Unless otherwise noted, all code is untested.
Common Answers: 1.(Loops, Viruses, etc.) 2. Search 3.RTFM |
|
| Back to top |
|
 |
DeathByNukes
Joined: 25 Mar 2007 Posts: 14 Location: Mabase
|
Posted: Sun Mar 25, 2007 3:52 am Post subject: |
|
|
I came across this topic and thought I'd share mine. I made it a long time ago so it might not use some of the newer stuff.
It fixes the maximized window problem by un-maximizing it and re-maximizing it.
It was designed to work on 2 side-by-side monitors that have equal resolution.
| Code: | ^+d:: ; Swap between 2 side-by-side monitors with the same resolution.
WinGet, sw_win, ID, A
sw_win = ahk_id %sw_win%
WinGetClass, sw_win_class, %sw_win%
if sw_win_class in Shell_TrayWnd,Progman,BaseBar
return ; desktop and taskbars
SysGet, sw_mon_left, 76
SysGet, sw_mon_area, 78
sw_mon_half := sw_mon_area / 2
WinGet, sw_win_max, MinMax, %sw_win%
sw_min_wasmax = %sw_win_max%
if ( sw_win_max != 0 )
WinRestore, %sw_win%
;Loop ; Wait for the window to restore.
;{
; WinGet, sw_win_max, MinMax, %sw_win%
; if ( sw_win_max = 0 )
; break
;
; if ( %A_Index% > 150 ) ; at least 7.5 seconds
; {
; SoundPlay, *16 ;stop/error
; return
; }
;
; Sleep, 50 ; 0.05 seconds
;}
WinGetPos, sw_win_x, sw_win_y, sw_win_width,, %sw_win%
; Move the window to the other side
if ( ( sw_win_x + (sw_win_width / 2) ) < sw_mon_half )
{ ; Is in 1st monitor.
WinMove, %sw_win%,, sw_win_x + sw_mon_half, sw_win_y
}
else
{ ; Is in 2nd monitor.
WinMove, %sw_win%,, sw_win_x - sw_mon_half, sw_win_y
}
; restore its previous state
if ( sw_min_wasmax = 1 )
WinMaximize, %sw_win%
else if ( sw_min_wasmax = -1 )
WinMinimize, %sw_win%
;variable cleanup
sw_win =
sw_mon_half =
sw_mon_left =
sw_mon_area =
sw_win_max =
sw_min_wasmax =
sw_win_x =
sw_win_y =
sw_win_width =
return |
|
|
| Back to top |
|
 |
neXt
Joined: 19 Mar 2007 Posts: 461
|
Posted: Sun Mar 25, 2007 6:40 am Post subject: |
|
|
Nice !!!  |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|