1. import WindowCaptureUtil¶

In [1]:
from WindowCaptureUtil import WindowCapture

2. list processes (optional)¶

In [ ]:
import win32gui
def winEnumHandler( hwnd, ctx ):
    if win32gui.IsWindowVisible( hwnd ):
        print ( "0x%08x"%(hwnd), win32gui.GetWindowText( hwnd ))

win32gui.EnumWindows( winEnumHandler, None )

3. get screenshot (for all windows)¶

In [2]:
cap = WindowCapture(window_name="계산기")
img = cap.get_screenshot() # window will be foreground

4. save image¶

In [3]:
from PIL import Image
import cv2
im = Image.fromarray(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
im.save("calc.jpg")

5. check the image¶

In [4]:
%matplotlib inline
from matplotlib import pyplot as plt

plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
plt.axis("off")
plt.tight_layout()
plt.show()
No description has been provided for this image

5. get screeshot (for native window apps)¶

In [5]:
cap = WindowCapture(window_name="팟플레이어")
img = cap.get_screenshot_of_native_appication() # window doesn't need to be foreground
In [6]:
%matplotlib inline
from matplotlib import pyplot as plt
import cv2
plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
plt.axis("off")
plt.tight_layout()
plt.show()
No description has been provided for this image