Post Reply
Tunga 2007-07-09 05:31
I'm wondering if it would be possible with scripting to switch all windows that are on my primary monitor onto my secondary and all that are on my secondary monitor onto my primary. Basically I want to work on my primary screen always because my secondary is not at a good angle but it's good for leaving things so I can keep an eye on them. As an example I might have a game and a browser open, so I'd like to switch the game to secondary and the browser to primary so I can look something up on the internet and then switch them back to carry on with the game. Is this easy/possible? Perhaps if there's no way to iterate through all windows I could at least do it with two hard-coded applications?
Any helps would be apprecaited, thanks :) .
|
Christian Studer 2007-07-09 09:05
Swapping two specific applications will work fine if they have known window titles, but swapping all windows won't work because the script can't get a list of all open windows.
To swap two applications, you could use the window object's Find method to get the window, then set the Monitor property to move it to the other monitor:Set wnd = CreateObject("UltraMon.Window")
If wnd.Find("Untitled - Notepad", "", 1, 0, 0) = True Then
wnd.Monitor = 2
wnd.ApplyChanges 0
End If
Christian Studer - www.realtimesoft.com
|
Tunga 2007-07-09 21:09
Thanks for quick reply, that's pretty much what I thought. I put this together to switch Firefox and World of Warcraft:
Dim wow
Set wow = CreateObject("UltraMon.Window")
Dim ffx
Set ffx = CreateObject("UltraMon.Window")
If wow.Find("World of Warcraft", "", FINDWND_TITLE, 0, 0) = True Then
If wow.Monitor = 1 Then
wow.Monitor = 2
Else
wow.Monitor = 1
End If
wow.ApplyChanges 0
End If
If ffx.Find("* - Mozilla Firefox", "", FINDWND_TITLE, 0, 0) = True Then
If ffx.Monitor = 1 Then
ffx.Monitor = 2
Else
ffx.Monitor = 1
End If
ffx.ApplyChanges 0
End If But it doesn't seem to work on either of the windows. In fact the only thing it will move is if I'm hovering the taskbar item for Firefox and the little Vista preview window comes up, it'll move that! I'm guessing that has the same name as Firefox so it's finding that which makes sense but then I don't get why it's not working on the actual Firefox. Any ideas?
|
Christian Studer 2007-07-10 09:34
Wildcards don't always work correctly, I'm going to look into this for one of the next releases.
If you get a match for one of the preview windows, you could add the window class to find the correct window.
I use Spy++ to get window classes, this is included with Visual Studio.
Christian Studer - www.realtimesoft.com
|
Tunga 2007-07-10 20:59
Well I figured out that it's not a wildcard issue since it does the same thing if I use the exact current name (e.g. "Google - Mozilla Firefox"). Interestingly even if I use the Window Class instead, it does the exact same thing: nothing unless the hover preview is up and then it moves that instead. I'm assuming those previews actually always exist so it's always moving that but if it's not currently being dispalyed then obviously I can't see it being moved so it looks like nothing happens. Any other ideas?
|
Christian Studer 2007-07-11 09:00
I'm not sure what might cause this, for me it works fine with Firefox if the whole window title is used.
Do you see the same problem with other applications, for example Notepad?
Christian Studer - www.realtimesoft.com
|
Tunga 2007-07-14 02:32
Yup, seems to be the same with every application in fact.
|
Christian Studer 2007-07-14 08:15
Unfortunately I don't know what might cause this, let me know if you find out anything else.
Christian Studer - www.realtimesoft.com
|
Post Reply
|