I use Python2.7, Win7 32bit.
import pyautogui
pyautogui.confirm(text=u'XXXX', title=r'XX', buttons=['OK', 'Cancel'])
pyautogui.click()
error:
Traceback (most recent call last):
File "VisualNovelForScroll.py", line 28, in <module>
pyautogui.click()
File "F:/Anaconda2/Lib/site-packages\pyautogui\__init__.py", line 362, in click
platformModule._click(x, y, 'left')
File "F:/Anaconda2/Lib/site-packages\pyautogui\_pyautogui_win.py", line 437, in _click
_sendMouseEvent(MOUSEEVENTF_LEFTCLICK, x, y)
File "F:/Anaconda2/Lib/site-packages\pyautogui\_pyautogui_win.py", line 480, in _sendMouseEvent
raise ctypes.WinError()
WindowsError: [Error 1400] 无效的窗口句柄。
My Windows language is Chinese. 无效的窗口句柄 means invalid windows handle
I try to get the mouse position and send it as arguments into pyautogui.click()
However I get the same error.`
pyautogui.confirm(text=u'XXXX', title=r'XX', buttons=['OK', 'Cancel'])
currentMouseX, currentMouseY = pyautogui.position()
pyautogui.click(currentMouseX, currentMouseY)
another failed attempt:
pyautogui.confirm(text=u'XXXX', title=r'XX', buttons=['OK', 'Cancel'])
currentMouseX, currentMouseY = pyautogui.position()
pyautogui.moveTo(currentMouseX, currentMouseY)
pyautogui.click()
Thanks in advance. Any advice will be appreciated.
I got this error and found that it still performs the click- try this:
try:
pyautogui.click()
except:
print "Error-carrying on anyway"
Or if you don't want it to print anything:
try:
pyautogui.click()
except:
pass