79583349

Date: 2025-04-20 12:27:27
Score: 0.5
Natty:
Report link

I went round the houses for weeks with this one. The solutions above did not work for me.

The sequence of terminal commands that finally got "Quartz" to work for me on a M2 Mac Sequoia 15.3.2 was the following:

pip install --upgrade pip

pip install pyobjc-framework-Quartz

pip install pyobjc

python3 -m pip install pyautogui

The key reference is at: https://pyautogui.readthedocs.io/en/latest/install.html

My script contained:

#!/bin/zsh
from Quartz.CoreGraphics import CGEventCreateMouseEvent
from Quartz.CoreGraphics import CGEventCreate
from Quartz.CoreGraphics import CGEventPost
from Quartz.CoreGraphics import CGEventGetLocation
from Quartz.CoreGraphics import kCGEventMouseMoved
from Quartz.CoreGraphics import kCGEventLeftMouseDown
from Quartz.CoreGraphics import kCGEventLeftMouseUp
from Quartz.CoreGraphics import kCGMouseButtonLeft
from Quartz.CoreGraphics import kCGHIDEventTap
import Quartz
import sys
import time

def mouseEvent(type, posx, posy):
    theEvent = CGEventCreateMouseEvent(None, type, (posx,posy), kCGMouseButtonLeft)
    CGEventPost(kCGHIDEventTap, theEvent)

def mousemove(posx,posy):
    mouseEvent(kCGEventMouseMoved, posx,posy)

def mouseclickdn(posx,posy):
    mouseEvent(kCGEventLeftMouseDown, posx,posy)

def mouseclickup(posx,posy):
    mouseEvent(kCGEventLeftMouseUp, posx,posy)

def mousedrag(posx,posy):
    mouseEvent(kCGEventLeftMouseDragged, posx,posy)


and the error message before the solution was:
Traceback (most recent call last):
  File "wmap1.py", line 2, in <module>
    from Quartz.CoreGraphics import CGEventCreateMouseEvent
ModuleNotFoundError: No module named 'Quartz'
Reasons:
  • Blacklisted phrase (1): did not work
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: user22695711