简体   繁体   English

Pyautogui 不在 Mac 上运行? (卡特琳娜)

[英]Pyautogui not running on Mac? (Catalina)

I'm trying to run the following from terminal on my mac, but what's happening is the code appears to run (I don't get any error message), python (as an app) on my mac bounces on my dock as if to open and then it doesn't do anything and then it stops running.我正在尝试从我的 Mac 上的终端运行以下命令,但发生的情况是代码似乎正在运行(我没有收到任何错误消息),我的 Mac 上的 python(作为应用程序)在我的扩展坞上弹跳,好像打开,然后它什么也不做,然后停止运行。 I can't tell if this is a permissions issue or a Mac Catalina issue or an issue with my code!我不知道这是权限问题、Mac Catalina 问题还是我的代码问题!

import pyautogui as gui
count= 0
gui.click(1080,521)
while count<5:
    gui.FAILSAFE=True
    gui.write(f'This is a test {count}x')
    count += 1
    gui.press('enter')

I've already tried to run the sudo command, I've also tried:我已经尝试运行 sudo 命令,我也尝试过:

gui.moveTo(1080,521)
gui.dragTo(button='left')

in place of the gui.click command, but nothing seems to be working?代替 gui.click 命令,但似乎没有任何效果? Help?帮助?

Turns out this was a permissions issue - in Mac System Preferences I needed to give access to Terminal to control my mouse原来这是一个权限问题 - 在 Mac 系统偏好设置中,我需要授予对终端的访问权限以控制我的鼠标

In my case with Big Sir System Env I did就我的 Big Sir System Env 而言,我做到了

setting -> security & privacy -> Accessibility -> Terminal 'check'设置 -> 安全和隐私 -> 辅助功能 -> 终端“检查”

It works well now.现在效果很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM