python win32api 句柄正确但点击失败
```python
def mouseClick(clickTimes,lOrR,img,reTry):
if reTry == 1:
while True:
location=pyautogui.locateCenterOnScreen('C:/Users/z1782/Desktop/waterRPA/' + img,confidence=0.9)
if location is not None:
# pyautogui.click(location.x,location.y,clicks=clickTimes,interval=0.2,duration=0.2,button=lOrR)
print("坐标:", location.x, location.y)
houtaiClick(location.x, location.y, 328290)
break
print("未找到匹配图片,0.1秒后重试")
time.sleep(0.1)
elif reTry == -1:
while True:
location=pyautogui.locateCenterOnScreen(img,confidence=0.9)
if location is not None:
# pyautogui.click(location.x,location.y,clicks=clickTimes,interval=0.2,duration=0.2,button=lOrR)
houtaiClick(location.x, location.y, 328290)
time.sleep(0.1)
elif reTry > 1:
i = 1
while i < reTry + 1:
location=pyautogui.locateCenterOnScreen(img,confidence=0.9)
if location is not None:
# pyautogui.click(location.x,location.y,clicks=clickTimes,interval=0.2,duration=0.2,button=lOrR)
houtaiClick(location.x, location.y, 328290)
print("重复")
i += 1
time.sleep(0.1)
def houtaiClick(x, y, hwnd):
print("x:",x,"y:", y, "hwnd", hwnd)
long_position = win32api.MAKELONG(x, y)
print("long_position",long_position)
time.sleep(0.05)
back1 = win32api.PostMessage(hwnd,win32con.WM_LBUTTONDOWN,win32con.MK_LBUTTON,long_position)
time.sleep(0.05)
back2 = win32api.PostMessage(hwnd, win32con.WM_LBUTTONUP, win32con.MK_LBUTTON,long_position)
![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/097087620756134.png "#left")