Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PIL ImageGrab to capture the selected window in Python

How can I use ImageGrab.grab()) in a specific manner to capture the selected window rather than the whole screen or boundary box?

For a better understanding, I am currently using this line below, which basically captures the given boundary box:

        screen =  np.array(ImageGrab.grab(bbox=(0,40,800,640)))

Thanks!

like image 200
HurpaDerpa Avatar asked Sep 15 '25 02:09

HurpaDerpa


1 Answers

After finding out of a package, called win32gui I have successfully solved this issue. Please refer to this link: Get window position & size with python

like image 111
HurpaDerpa Avatar answered Sep 16 '25 16:09

HurpaDerpa