Skip to content

ohsungkim56/WindowCaptureUtil

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

1. import WindowCaptureUtil

from WindowCaptureUtil import WindowCapture

2. list processes (optional)

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)

cap = WindowCapture(window_name="계산기")
img = cap.get_screenshot() # window will be foreground

4. save image

from PIL import Image
import cv2
im = Image.fromarray(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
im.save("calc.jpg")

5. check the image

%matplotlib inline
from matplotlib import pyplot as plt

plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
plt.axis("off")
plt.tight_layout()
plt.show()

png

5. get screeshot (for native window apps)

cap = WindowCapture(window_name="팟플레이어")
img = cap.get_screenshot_of_native_appication() # window doesn't need to be foreground
%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()

png

About

WindowCaptureUtil

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors