I have two monitors connected to my computer with both active at the same time. The monitors are not mirrored - each displays different content.
I need to be able to select in code which of these two monitors I want to use with sct.grab.
I have seen and tested this code: sct_img = sct.grab(sct.monitors[1]) It works - I can change the "1" to "2" and it will indeed screenshot the other monitor - all of it. However, I can't figure out how to pass into sct.grab both the parameters for the monitor I wish to use, AND the region of screen I wish to grab for just a partial screenshot. It seems I can either get a partial screenshot, but not choose the monitor, or I can choose the monitor, but only get the full screen. I need to choose the monitor, and also choose the region. I'm looking for help with the appropriate syntax.
I have this code:
sct_img = sct.grab({'top': 160, 'left': 160, 'width': 160, 'height': 135})
but what I want is somewhere to tell sct.grab which of my two monitors to get this from: For example, something like a parameter in the dictionary specifying which monitor to use would be nice:
sct_img = sct.grab({'mon': 2, 'top': 160, 'left': 160, 'width': 160, 'height': 135})
Any help would be apprecitated.
There is currently no automatic way of doing that in MSS. Your best shot is to calculate coordinates using values stored in
sct.monitors
.Something like: