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 windows over three monitors

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
SuperLarryo



Joined: 15 May 2008
Posts: 2
Location: Middle of Nowhere

PostPosted: Thu May 15, 2008 9:29 pm    Post subject: Moving windows over three monitors Reply with quote

Hello AHK community.

I have been working with AHK for a few weeks now, and I am officially stuck. I tried to write a program to automatically create three windows, and then distribute each one to a separate monitor. I can get this to work for two monitors, and I have already viewed several other topics like this for examples. I want this program to be able to start up, create three windows at different URLs, and then move them to different monitors. Here is what I have so far:

Code:
;creates first window
Run, firefox.exe http://hobbit.roc.net/hobbit/
WinGetActiveTitle, ActTitle
WinActivate %ActTitle%
;I can't get this to work without a hotkey, so I made Ctrl-Right do the rest
^Right::GoSub, MoveWindow

MoveWindow:
SysGet, Mon, Monitor, 1
   WinGetActiveTitle, ActTitle
   WinGetPos, X, Y,,,%ActTitle%,,,
   ;determine which monitor it's on to see which one to move it to
   if(X < (MonRight - 4))
      GoSub, MoveWindowToRightScreen

MoveWindowToRightScreen:
   WinGetActiveTitle, ActTitle
   WinGetPos, X, Y,,,%ActTitle%,,,
   if(X < (MonRight - 4)){
      WinGet, state, MinMax, %ActTitle%
      if(state = 1){
         WinRestore, %ActTitle%
      }
      ;moves the first window to the third monitor
      newx := X + 2048
      WinMove,%ActTitle%,,%newx%,Y
}
;creates second window
Run, firefox.exe http://hobbit.roc.net/hobbit/network/network.html
WinGetActiveTitle, ActTitle2
WinActivate %ActTitle2%
GoSub, MoveWindow2

MoveWindow2:
SysGet, Mon, Monitor, 1
   WinGetActiveTitle, %ActTitle2%
   WinGetPos, X, Y,,,%ActTitle2%,,,
   ;determine which monitor it's on to see which one to move it to
   if(X < (MonRight - 4))
      GoSub, MoveWindowToRightScreen2

MoveWindowToRightScreen2:
   WinGetActiveTitle, %ActTitle2%
   WinGetPos, X, Y,,,%ActTitle2%,,,
   if(X < (MonRight - 4)){
      WinGet, state, MinMax, %ActTitle2%
      if(state = 1){
         WinRestore, %ActTitle2%
      }
      ;moves second window to second monitor (this is the part that doesn't work)
      newx := X + 1024
      WinMove,%ActTitle2%,,%newx%,Y
}
;creates the third window and leaves it at the first monitor, which actually works
Run, firefox.exe http://hobbit.roc.net/hobbit/rocnet/rocnet.html
WinGetActiveTitle, ActTitle3
WinActivate %ActTitle3%
ExitApp


This is a modification of some code I found elsewhere on this site. The first window and third window go where I need them to, but the second window does not move off of the primary monitor. I also can't get any of this to work without that first ^Right hotkey. Could somebody give me a few pointers? It seems that no matter what I try, I can't get this to work correctly. Any help at all would be appreciated.

(I don't need the windows maximized, I have a Firefox add-on that makes them full screen when created).
Back to top
View user's profile Send private message MSN Messenger
keybored



Joined: 18 Jun 2006
Posts: 89
Location: Phoenix, AZ

PostPosted: Sat May 17, 2008 7:29 am    Post subject: hmm Reply with quote

OK I see at least part of the problem (see error message below).
You had the variable enclosed in %%
WinGetActiveTitle, ActTitle2


Error: The following variable name contains an illegal character:
"roc.net - Roc Recruitment, Roc Cleanser, The Roc Project - Mozilla Firefox"

The current thread will exit.

...
033: Gosub,MoveWindow2
036: SysGet,Mon,Monitor,1
---> 037: WinGetTitle,%ActTitle2%,A
038: WinGetPos,X,Y,,,%ActTitle2%,,
040: if (X < (MonRight - 4))
...
Back to top
View user's profile Send private message
SuperLarryo



Joined: 15 May 2008
Posts: 2
Location: Middle of Nowhere

PostPosted: Mon May 19, 2008 9:54 pm    Post subject: Reply with quote

Thank you for that. I got this to finally work today, but I had to split each window into separate programs that chain activate and close as each finish. Though it works now, I would prefer it to all be in one program. Oh well.
Back to top
View user's profile Send private message MSN Messenger
keybored



Joined: 18 Jun 2006
Posts: 89
Location: Phoenix, AZ

PostPosted: Tue May 20, 2008 3:49 am    Post subject: the code Reply with quote

Post the updated code I will have another look.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help 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