asweigart / pyautogui

A cross-platform GUI automation Python module for human beings. Used to programmatically control the mouse & keyboard.
BSD 3-Clause "New" or "Revised" License
10.22k stars 1.24k forks source link

The code is unreachable problem #668

Open aa3507943 opened 2 years ago

aa3507943 commented 2 years ago

After using pyautogui.screenshot() function, if there are still codes behind it, they will be unreachable. Please help to verify it

unit254 commented 2 years ago

I have the same problem. Tought i did something wrong because im new to it.

pyautogui 0.9.53

` import cv2 as cv import pyautogui

pos = pyautogui.position() pyautogui.screenshot('screenshot.png' )

After here it is greyed

screenshot = cv.imread("screenshot.png") screenshot = cv.resize(screenshot, (0, 0),fx=0.5,fy=0.5) cv.imshow("Testing", screenshot) cv.waitKey(0)`

image

unit254 commented 2 years ago

After using pyautogui.screenshot() function, if there are still codes behind it, they will be unreachable. Please help to verify it

Rolling back to Pylance version 2022.2.1 solved the problem.

itsmichaelk commented 2 years ago

But it seems not to be unreachable. The IDE says so, but when you do this:

import pyautogui as pg
import cv2 as cv

capture = pg.screenshot()
print('test')

The 'test' will still be printed..