Skip to content Skip to sidebar Skip to footer

Detecting Lock Screen On Mac Through Python3

Trying to find a way to detect if the screen is locked on a Mac system, using Python3 I've tried the following, and it gives a KeyError: import Quartz gui_dict = Quartz.CGSessionCo

Solution 1:

Install quartz - pip install pyobjc-framework-Quartz

Much simple code -

import Quartz
d = Quartz.CGSessionCopyCurrentDictionary()
print('CGSSessionScreenIsLocked'in d.keys())

Post a Comment for "Detecting Lock Screen On Mac Through Python3"