简体   繁体   中英

Python: PyautoGui Mouse Click Not working neither locateScreen based on screenshot

Below code stops after printing hello and nothing happens. Tried different option as pyautogui.leftClick(993, 578) but no luck. In below code if I don't use subprocess but keep zoom GUI open then click is working fine.

import subprocess
import pyautogui
import time
import os
import pandas as pd
from datetime import datetime

print("hello")
subprocess.call("C:\\Users\xyz\\AppData\\Roaming\\Zoom\\bin\\Zoom.exe")
time.sleep(5)
pyautogui.moveTo(993, 578, 0)
pyautogui.leftClick()
print(1)

The simple problem i see with your code is this line:

subprocess.call("C:\\Users\xyz\\AppData\\Roaming\\Zoom\\bin\\Zoom.exe")

You've missed a \ before the xyz .

The following works perfectly for me on Python 3.6+:

import pyautogui
import time
import os

print("begun")
os.system(r"C:\Users\xyz\AppData\Roaming\Zoom\bin\Zoom.exe")
time.sleep(5)
pyautogui.moveTo(pyautogui.locateCenterOnScreen('my image'))
pyautogui.click()
print("dun")

If this doesn't work, try the pydirectinput module too, it's the updated version of pyautogui with much the same functions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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