Skip to main content

This package which helps you to take screenshot of specific running window

Project description

wscreenshot

wscreenshot is a package which helps you to take screenshot of active windows running in windows OS. You just have to specify the name of the window which you want to take screen shot.

If you don't specify name of any window it takes the default screenshot of current view.

Implemented using win32 library and numpy so that it can be directly used by opencv.

To take Default Screenshot

from wscreenshot import Screenshot
import cv2 as cv
k = Screenshot()
x = k.screenshot()
cv.imshow('My Screenshot', x)
cv.waitKey(0) 
cv.destroyAllWindows()  

To list out the active windows you can use

import wscreenshot
wscreenshot.list_window_names()

This prints all the active windows.

To take screenshot of only specific window use

obj = Screenshot('Name of the window')

or

obj = Screenshot(window_name = 'Name of the window')

Example to take the screenshot of File Explorer which is currently running

To get the exact name of the window use wscreenshot.list_window_names()

from wscreenshot import Screenshot
import cv2 as cv
k = Screenshot('File Explorer')
x = k.screenshot()
cv.imshow('My Screenshot', x)
cv.waitKey(0) 
cv.destroyAllWindows()  

For taking the cropped screenshot you can specify width and height of the image

obj.screenshot(w = None, h = None)

Example:

from wscreenshot import Screenshot
import cv2 as cv
k = Screenshot()
x = k.screenshot(w = 200)
cv.imshow('My Screenshot with width 200', x)
cv.waitKey(0) 
cv.destroyAllWindows()  
x = k.screenshot(h = 200)
cv.imshow('My Screenshot with height 200', x)
cv.waitKey(0) 
cv.destroyAllWindows()  
x = k.screenshot(w = 200, h = 200)
cv.imshow('My Screenshot with width and height 200', x)
cv.waitKey(0) 
cv.destroyAllWindows()  

Advance stuff

This can be used to process games and lot many stuff

To capture each frame we can use

from wscreenshot import Screenshot
from time import time
import cv2 as cv
wincap = Screenshot('name of some active window')
loop_time = time()
while True :
    screenshot = wincap.screenshot()
    cv.imshow('Computer Vision', screenshot)
    print(f'FPS { 1 / (time() - loop_time) }')
    loop_time = time()
    if cv.waitKey(1) == ord('q'):
        cv.destroyAllWindows()
        break
print('Done.')

This can be used from processing a game or many image processing application where you can capture each frame and process the image.

Limitations

It will take blank screenshot for applications build using electron and some other framework. Will try to resolve in next update

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wscreenshot-0.0.3.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wscreenshot-0.0.3-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file wscreenshot-0.0.3.tar.gz.

File metadata

  • Download URL: wscreenshot-0.0.3.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for wscreenshot-0.0.3.tar.gz
Algorithm Hash digest
SHA256 7cc876662753529acef076bda1f7e7151010f956d5baadcca687e8945128186e
MD5 bfcfe9484d7168b331a92edb78209b7d
BLAKE2b-256 7b3e1cf42779932c02e776934f8f22101e2fe24663a209b96b07063b98a16bd7

See more details on using hashes here.

File details

Details for the file wscreenshot-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: wscreenshot-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.7

File hashes

Hashes for wscreenshot-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0e150a6c0569125715bbd6d7d348d0982dc18d02afc442a3eb8a1ffc7b1c850e
MD5 a0a989abc80342121adfdd15df8cbccf
BLAKE2b-256 ce48e16e2adadd70faf515880f8f47c6d106e26127322ad288ba3fac4807a806

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page