"""Read-only permission checks; never open prompts or change system settings.""" import ctypes import sys def mouse_permission_granted(): if sys.platform != 'darwin': return True framework = ctypes.CDLL('/System/Library/Frameworks/ApplicationServices.framework/ApplicationServices') framework.AXIsProcessTrusted.restype = ctypes.c_bool return bool(framework.AXIsProcessTrusted()) if __name__ == '__main__': print('辅助功能权限已授予' if mouse_permission_granted() else '辅助功能权限未授予')