我使用try /除了两次运行函数解决了一些问题。
最后一次使用" pyautogui"。如果我尝试使用pyautogui.doubleClick(100,100)
在Windows 8.1上模拟双击鼠标,我会得到响应" PermissionError [WinError 5]"。
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
pg.doubleClick(1210,110)
File "C:\Python34\lib\site-packages\pyautogui\__init__.py", line 458, in doubleClick
click(x, y, 2, interval, button, _pause=False)
File "C:\Python34\lib\site-packages\pyautogui\__init__.py", line 362, in click
platformModule._click(x, y, 'left')
File "C:\Python34\lib\site-packages\pyautogui\_pyautogui_win.py", line 436, in _click
_sendMouseEvent(MOUSEEVENTF_LEFTCLICK, x, y)
File "C:\Python34\lib\site-packages\pyautogui\_pyautogui_win.py", line 479, in _sendMouseEvent
raise ctypes.WinError()
PermissionError: [WinError 5] Acesso negado.
但我可以使用try / except两次解决:
try:
pyautogui.doubleClick(1210,110)
except:
try:
pyautogui.doubleClick(1210,110)
except:
pass
有人可以告诉我发生了什么?
答案 0 :(得分:1)
我遇到pyautogui.doubleClick()
的问题,没有点击...
但是,在documentation page中,我还看到了关键字参数clicks
,您可以像这样使用它:
pyautogui.click(x=87, y=227, clicks=2) # double left click on the point(x,y)
对我来说,它奏效了! :)