Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

Trigger kb/m control and screen recording prompts on macOS

Dillon DuPont907952bff6f8
diff --git a/libs/python/computer-server/computer_server/handlers/macos.py b/libs/python/computer-server/computer_server/handlers/macos.py
index 6a831c177a..5692bea306 100644
--- a/libs/python/computer-server/computer_server/handlers/macos.py
+++ b/libs/python/computer-server/computer_server/handlers/macos.py
@@ -55,6 +55,34 @@ from .base import BaseAccessibilityHandler, BaseAutomationHandler
logger = logging.getLogger(__name__)
+# Trigger accessibility permissions prompt on macOS
+try:
+ # Source - https://stackoverflow.com/a/17134
+ # Posted by Andreas
+ # Retrieved 2025-12-03, License - CC BY-SA 4.0
+ # Attempt to create and post a mouse event to trigger the permissions prompt
+ # This will cause macOS to show "Python would like to control this computer using accessibility features"
+ current_pos = CGEventGetLocation(CGEventCreate(None))
+ p = CGPoint()
+ p.x = current_pos.x
+ p.y = current_pos.y
+
+ me = CGEventCreateMouseEvent(None, kCGEventMouseMoved, p, 0)
+ if me:
+ CGEventPost(kCGHIDEventTap, me)
+ CFRelease(me)
+except Exception as e:
+ logger.debug(f"Failed to trigger accessibility permissions prompt: {e}")
+
+# Trigger screen recording prompt on macOS
+try:
+ import pyautogui
+
+ pyautogui.screenshot()
+except Exception as e:
+ logger.debug(f"Failed to trigger screenshot permissions prompt: {e}")
+
+
# Constants for accessibility API
kAXErrorSuccess = 0
kAXRoleAttribute = "AXRole"