Skip to content

Commit beb43ae

Browse files
authored
Windows: Capture all visible windows
1 parent dd52984 commit beb43ae

File tree

9 files changed

+54
-32
lines changed

9 files changed

+54
-32
lines changed

CHANGELOG

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ History:
22

33
<see Git checking messages for history>
44

5-
dev 2017/xx/xx
5+
dev 2018/xx/xx
66
- removed support for Python 3.3
77
- CI: build the documentation
88
- doc: improvements and fixes (fix #37)
99
- MSS: possibility to get the whole PNG raw bytes
10+
- Windows: capture all visible windows (fix #28, #29)
1011

1112
3.1.1 2017/11/27
1213
- MSS: add the 'mss' entry point

CHANGES.rst

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,59 @@
1-
3.1.0 (2017-08-xx)
1+
3.1.2 (2018-01-xx)
22
==================
33

4+
tools.py
5+
--------
6+
- Changed signature of ``to_png(data, size, output)`` to ``to_png(data, size, output=None)``. If ``output`` is ``None``, the raw PNG bytes will be returned.
7+
8+
9+
3.1.1 (2017-11-27)
10+
==================
11+
12+
__main__.py
13+
-----------
14+
- Added ``args`` argument to ``main()``
15+
416
base.py
517
-------
6-
- Moved `ScreenShot` class to screenshot.py
18+
- Moved ``ScreenShot`` class to screenshot.py
719

820
darwin.py
921
---------
10-
- Removed `get_infinity()` function
11-
- Removed `resize()` method. Use `_crop_width()` method instead.
22+
- Add ``CGPoint.__repr__()``
23+
- Add ``CGRect.__repr__()``
24+
- Add ``CGSize.__repr__()``
25+
- Removed ``get_infinity()`` function
1226

1327
windows.py
1428
----------
15-
- Added `scale_factor` property to `MSS` class
16-
- Added `scale()` method to `MSS` class
29+
- Added ``scale()`` method to ``MSS`` class
30+
- Added ``scale_factor`` property to ``MSS`` class
1731

1832

1933
3.0.0 (2017-07-06)
2034
==================
2135

2236
base.py
2337
-------
24-
- Added the `ScreenShot` class containing data for a given screen shot (support the Numpy array interface [`ScreenShot.__array_interface__`])
25-
- Add `shot()` method to `MSSBase`. It takes the same arguments as the `save()` method.
26-
- Renamed `get_pixels` to `grab`. It now returns a `ScreenShot` object.
27-
- Moved `to_png` method to `tools.py`. It is now a simple function.
28-
- Removed `enum_display_monitors()` method. Use `monitors` property instead.
29-
- Removed `monitors` attribute. Use `monitors` property instead.
30-
- Removed `width` attribute. Use `ScreenShot.size[0]` attribute or `ScreenShot.width` property instead.
31-
- Removed `height` attribute. Use `ScreenShot.size[1]` attribute or `ScreenShot.height` property instead.
32-
- Removed `image`. Use the `ScreenShot.raw` attribute or `ScreenShot.rgb` property instead.
33-
- Removed `bgra_to_rgb()` method. Use `ScreenShot.rgb` property instead.
38+
- Added the ``ScreenShot`` class containing data for a given screen shot (support the Numpy array interface [``ScreenShot.__array_interface__``])
39+
- Add ``shot()`` method to ``MSSBase``. It takes the same arguments as the ``save()`` method.
40+
- Renamed ``get_pixels`` to ``grab``. It now returns a ``ScreenShot`` object.
41+
- Moved ``to_png`` method to ``tools.py``. It is now a simple function.
42+
- Removed ``enum_display_monitors()`` method. Use ``monitors`` property instead.
43+
- Removed ``monitors`` attribute. Use ``monitors`` property instead.
44+
- Removed ``width`` attribute. Use ``ScreenShot.size[0]`` attribute or ``ScreenShot.width`` property instead.
45+
- Removed ``height`` attribute. Use ``ScreenShot.size[1]`` attribute or ``ScreenShot.height`` property instead.
46+
- Removed ``image``. Use the ``ScreenShot.raw`` attribute or ``ScreenShot.rgb`` property instead.
47+
- Removed ``bgra_to_rgb()`` method. Use ``ScreenShot.rgb`` property instead.
3448

3549
darwin.py
3650
---------
37-
- Removed `_crop_width()` method. Screen shots are now using the width setted by the OS (rounded to 16).
51+
- Removed ``_crop_width()`` method. Screen shots are now using the width setted by the OS (rounded to 16).
3852

3953
exception.py
4054
------------
41-
- Renamed `ScreenshotError` class to `ScreenShotError`
55+
- Renamed ``ScreenshotError`` class to ``ScreenShotError``
4256

4357
tools.py
4458
--------
45-
- Changed signature of `to_png(data, monitor, output)` to `to_png(data, size, output)` where `size` is a `tuple(width, height)`
59+
- Changed signature of ``to_png(data, monitor, output)`` to ``to_png(data, size, output)`` where ``size`` is a ``tuple(width, height)``

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
MIT License
2-
Copyright (c) 2016-2017, Mickaël 'Tiger-222' Schoentgen
2+
Copyright (c) 2016-2018, Mickaël 'Tiger-222' Schoentgen
33

44
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
55

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
# General information about the project.
2525
project = 'Python MSS'
26-
copyright = "2013-2017, Mickaël 'Tiger-222' Schoentgen & contributors"
26+
copyright = "2013-2018, Mickaël 'Tiger-222' Schoentgen & contributors"
2727
author = 'Tiger-222'
2828

2929
# The version info for the project you're documenting, acts as replacement for

docs/source/where.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ This is a non exhaustive list where MSS is integrated or has inspired.
66
Do not hesistate to `say Hello! <https://github.com/BoboTiG/python-mss/issues>`_ if you are using MSS too.
77

88

9-
Computer Vison
10-
==============
9+
AI, Computer Vison
10+
==================
1111

1212
- `DoomPy <https://github.com/WNoxchi/DoomPy>`_ (Autonomous Anti-Demonic Combat Algorithms);
1313
- `Europilot <https://github.com/jsistla/eu-pilot>`_, a self-driving algorithm using Euro Truck Simulator (ETS2);

mss/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
__version__ = '3.1.2'
1717
__author__ = "Mickaël 'Tiger-222' Schoentgen"
1818
__copyright__ = """
19-
Copyright (c) 2013-2017, Mickaël 'Tiger-222' Schoentgen
19+
Copyright (c) 2013-2018, Mickaël 'Tiger-222' Schoentgen
2020
2121
Permission to use, copy, modify, and distribute this software and its
2222
documentation for any purpose and without fee or royalty is hereby

mss/__main__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,16 @@ def main(args=None):
4040
}
4141
if options.coordinates:
4242
try:
43-
top, left, width, height = map(int, options.coordinates.split(','))
43+
top, left, width, height = options.coordinates.split(',')
4444
except ValueError:
4545
print('Coordinates syntax: top, left, width, height')
4646
return 2
4747

4848
kwargs['mon'] = {
49-
'top': top,
50-
'left': left,
51-
'width': width,
52-
'height': height,
49+
'top': int(top),
50+
'left': int(left),
51+
'width': int(width),
52+
'height': int(height),
5353
}
5454
if options.output == 'monitor-{mon}.png':
5555
kwargs['output'] = 'sct-{top}x{left}_{width}x{height}.png'

mss/tools.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,5 @@ def to_png(data, size, output=None):
5353
fileh.write(b''.join(ihdr))
5454
fileh.write(b''.join(idat))
5555
fileh.write(b''.join(iend))
56+
57+
return None

mss/windows.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515
__all__ = ('MSS',)
1616

1717

18+
CAPTUREBLT = 0x40000000
19+
DIB_RGB_COLORS = 0
20+
SRCCOPY = 0x00CC0020
21+
22+
1823
class BITMAPINFOHEADER(ctypes.Structure):
1924
""" Information about the dimensions and color format of a DIB. """
2025

@@ -196,10 +201,10 @@ def grab(self, monitor):
196201
monitor['width'], monitor['height'],
197202
srcdc,
198203
monitor['left'], monitor['top'],
199-
0xcc0020) # SRCCOPY
204+
SRCCOPY | CAPTUREBLT)
200205

201206
bits = ctypes.windll.gdi32.GetDIBits(
202-
memdc, bmp, 0, monitor['height'], data, bmi, 0)
207+
memdc, bmp, 0, monitor['height'], data, bmi, DIB_RGB_COLORS)
203208
if bits != monitor['height']:
204209
del data
205210
raise ScreenShotError('gdi32.GetDIBits() failed.', locals())

0 commit comments

Comments
 (0)