-
-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Screen reconfiguration not handled correctly #79
Comments
Hello, Thanks for the report and analysis! Turning If we could set a hook to know when a monitor is added or removed, it would be the best way: efficient and easy. I do not know of such API but some research will have to be done. Do you have time to investigate? The process can be only related to one OS, others will eventually come later. |
What about having the monitor detection in the MSS constructor? That way it is not done in every screenshot, but only when the MSS object is created? That way users could decide how often monitor detection is done, so to have a script taking screenshots every minute and doing monitor detection every time, one would have: while True:
time.sleep(60)
with mss() as sct:
sct.shot() and for low overhead one would use: with mss() as sct:
while True:
time.sleep(1)
sct.shot() Would that be a solution? |
Hm this is already the case :) |
I'm sorry, but it is not the case. You are mistaken. The first snippet will not detect new monitors as expected, because Line 27 in f3c83cf
Inserting a If you like I could prepare a pull request. |
Good catch, I stand corrected. I would be very happy to merge your PR :) |
Release 3.3.2 is published with your patch :) |
amazing!!1!! :-) |
General informations:
Description of the warning/error
Full message
no message
Other details
The reason is that the "_monitors" is a class varable of MSSBase
python-mss/mss/base.py
Line 19 in f3c83cf
and it is only initialized once per script run:
python-mss/mss/linux.py
Line 347 in f3c83cf
One possible solution is to turn "_monitors" into a member variable.
The text was updated successfully, but these errors were encountered: