Python: Opening process on a certain screen
I wrote a sc开发者_高级运维ript for myself so when I login to the computer 4 IE windows auto start. I tried to use the webbrowser module but it would load the 4 links into 1 IE window with tabs. I could not get webbrowser to open 4 different windows so I used subprocess.Popen.
I have 4 monitors and I want each instance of IE to automatically start on the appropriate screen. Right now I can only get the 4 windows to load behind eachother on the main screen. How can I accomplish this? I have googled and googled and I cannot find anything about opening the process with certain dimensions or on a certain screen... Here is my script:
import subprocess
subprocess.Popen('"C:\\Program Files\\Internet Explorer\\iexplore.exe" hxxps://myserver.com/Orion/SummaryView.aspx?viewid=1')
subprocess.Popen('"C:\\Program Files\\Internet Explorer\\iexplore.exe" hxxp://myserver2.com:8080/WOListView.do')
subprocess.Popen('"C:\\Program Files\\Internet Explorer\\iexplore.exe" hxxp://myserver3.com:8888/stats/cgi?sid=301960859109&area=stats&action=noc&id=22689236889&page=22&sel=tab_listview_sel_22689236889')
subprocess.Popen('"C:\\Program Files\\Internet Explorer\\iexplore.exe" hxxps://mymail.com/owa/')
I doubt you can do this with Python standard cross-platform functions alone. Using Windows API you can specify application window starting position and size with dwX
, dwY
, dwXSize
, dwYSize
members of the STARTUPINFO
structure passed to the CreateProcess
function. There are probably examples out there of using CreateProcess
with Python ctypes
FFI facility. Multi-monitor setup essentially provides one big virtual desktop with continuous coordinate system, so by setting these parameters you can make each window to appear on a separate monitor. Again, you need Windows API to determine coordinates of each monitor inside this big virtual screen space, namely EnumDisplayMonitors
and GetMonitorInfo
functions. Or, since you are probably never going to use it on any other machine, you can determine screen offsets experimentally and hardcode them.
精彩评论