'Moving window between monitors when using multiple desktops
The following script moves window from my left monitor to the right monitor (2560x1440 each)
win = win32gui.GetForegroundWindow()
winPlacement = list(win32gui.GetWindowPlacement(win))
left, top, right, bottom = winPlacement[4]
winPlacement[4] = (left + 2560, top, right + 2560, bottom)
win32gui.SetWindowPlacement(win, winPlacement)
At first glance, the function is working fine - window is moved to the same spot but on the right monitor. It stays in this position as long as I am on the same desktop.
But when I switch to another desktop (CTRL + WIN + →) and return back (CTRL + WIN + ←) the window is back on it's original position. I tried to use function MoveWindow
but it behaves the same. This problem is not present when the window is moved withing the bounds of the same monitor.
It seems like windows is storing this old position somewhere and applying it back every time I switch to another desktop. Is this a bug or do I have to do something else to make this new position permament?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|