WindowsError [5]运行Pyautogui时拒绝访问

时间:2016-09-24 02:19:52

标签: python windows command-prompt minecraft pyautogui

我有一个程序可以使用左右键单击以在Minecraft服务器上自动执行耕作作业。这是代码:

import pyautogui as pag
from time import sleep

pag.FAILSAFE = True

sleep(7)
def main():
    try:
        while True:
            pag.click(button="right")
            sleep(0.07)
            pag.click(button="left")
            sleep(0.07)
    except KeyboardInterrupt:
        print "[Error] Keyboard Interrupt"

main()
print "Done"

raw_input()

当我运行此操作时,会发出一个冗长的错误,说明运行pag.click(button="right")行时出现问题。这是完整的错误:

Traceback (most recent call last):
  File "C:\Users\wayde\Desktop\farmer.py", line 17, in <module>
    main()
  File "C:\Users\wayde\Desktop\farmer.py", line 10, in main
    pag.click(button="right")
  File "C:\Python27\lib\site-packages\pyautogui\__init__.py", line 366, in click
    platformModule._click(x, y, 'right')
  File "C:\Python27\lib\site-packages\pyautogui\_pyautogui_win.py", line 441, in _click
    _sendMouseEvent(MOUSEEVENTF_RIGHTCLICK, x, y)
  File "C:\Python27\lib\site-packages\pyautogui\_pyautogui_win.py", line 480, in _sendMouseEvent
    raise ctypes.WinError()
WindowsError: [Error 5] Access is denied.

我已尝试在以管理员身份运行的命令提示符下运行它,但这似乎不起作用。我有一个类似的程序,可以在我的旧笔记本电脑上运行,但它不能在这台机器上运行。

0 个答案:

没有答案