python-wnck has Screen object which combines the areas of multiple monitors and gives it in get_screen_size(). How to get the size of individual monitors. I am trying to move a window from one monitor to another
There are a lot of methods listed here : How do I get monitor resolution in Python?
I'm not sure if all the methods works for multiple screens. If you're using Window, try to run this code : http://code.activestate.com/recipes/460509-get-the-actual-and-usable-sizes-of-all-the-monitor/
Related
I have build a game in python, which uses OpenCV to fingerspell letters.
Through the first iteration of the program I have stumbled upon a problem regarding creating a GUI interface.
The problem is that I am using two python script one for recognition and one for displaying what the user currently fingerspelled.
I would like to make the two scripts run in a shared GUI like tKinter or PySimpleGui but without succeding.
I have used threading to run both python scripts to share data between them. As of now my solution is to click on the other window between letters which is not optimal.
Window for recognition:
Window for results:
So I would like the two windows to get merged into one is this possible in any way?
Why do you need this to be multithreaded?
Inside your game simply take a picture of the person on each draw loop and get the letter from that image.
If you need to display it you can always blit it to your pygame surface.
enter image description here
enter image description here
I want to draw a figure on another application as above. How can I do that? I tried using a window handle in c#, so I didn't get the result I wanted.
You could draw a transparent window on top of your target application, effectively creating an overlay. This would most likely involve quite a bit direct usage of the Win32 API. See for example enumerating windows of another application.
But it will likely be an unreliable solution since there is a whole bunch of things you need to take into account:
Ensure that the target application still receives all input events.
Ensure that your transparent window stays on top of the target application
Monitor the target application for any window size change, or minimizing/maximizing
Many more things that you will likely discover later
Note that this will likely not work for full screen applications, and while this should allow for an overlay, any data on what or where to draw things need to come from somewhere else.
My goal is to take screenshots off an application while the laptop screen is off, but instead the screenshot will always be the same as just before turning off the screen. It does not redraw itself once the screen is off, and remains frozen.
I'm obtaining a screenshot using printwindow from Python (using method described here: Python Screenshot of inactive window PrintWindow + win32gui
This method works nicely as long as I have my laptop screen on, but if I turn it off, it simply returns the last image before the screen turned off. I've tried using win32gui.RedrawWindow, hoping that this would force a redraw, but I haven't gotten it to work, even trying all the different flags. I've also tried getting screenshots via pyautogui, but this also has the same problem. Is there any way to redraw the application while the laptop screen is off?
It would be nice if there were a straightforward way to do what you want to do, but unfortunately it's just not possible without some convoluted low-level work.
In the underlying WinAPI, native windows redraw themselves only when they receive WM_PAINT messages, and they only receive WM_PAINT messages if they are visible. They don't get the messages if they're behind another window, or if they're dragged off screen, or minimized, or their visibility is set to False. They also aren't visible when the screen is off. Since they aren't visible, they simply never get told to redraw themselves. That's why the screen capture image doesn't change after the screen is turned off.
There is no command you can issue that will override this -- it is implemented as a fundamental part of the windowing paradigm.
One solution is to have the application paint itself in something that's not a window (e.g., a dialog box) and capture that rather than capturing the screen. You could also modify the application by overriding OnPaint and using a timer to invalidate and call your OnPaint function periodically (since WM_PAINT messages won't be received).
If it were me I'd override OnPaint, make my application draw itself to a background context bitmap rather than the normal window, then use a timer to invalidate and redraw periodically and just take the bitmap of the background context whenever I wanted to capture the output.
If you don't own the code for the applications that are running, you may still be able to get applications to redraw themselves by running everything in a virtual machine. I've done that successfully for headless computing in the past, but it was many OS versions ago and things may be different now, so YMMV...
Information on manual screenshots under VMWare is here.
Information on programmatic screenshots under Hyper-V is here.
I am trying some video processing exercises, and wondering if there is a way to display multiple video streams into one window a la pyplot.subplot command for the images.
I've tried using subplot syntax, but using it freezes the program, so any alternative source would be much appreciated.
It is possible to display multiple videos(e.g 2-videos can be displayed for dual core processor) at a time for that you have use OpenMP. It is possible if your using opencv. And it is pretty easy Only you have to enable OpenMp in your property sheet.
Here is the objective I wish to achieve: I would like to connect multiple web cameras to a single Windows machine and take snapshots from one of them at different instances (so one camera must active at one point of time, while another must be active at another). From what I have tried, an user has to go to the control panel and set which camera should be active at a given moment to use it. Is there a way to achieve this objective via python? (If there is a way to keep all cameras active at once, how should I specify which camera should take a snapshot?
I have investigated a couple options since then. One of the tools that I could utilize is devcon, through which usb cameras could be disabled/enabled to take snapshots. Another (simpler) option is to use a function in python opencv - cv2.VideoCapture(i) will automatically allow the program to iterate through different camera devices connected to the computer via usb.