为什么pyautogui点击不实际点击

为什么pyautogui点击不实际点击

本文介绍了为什么pyautogui点击不实际点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用Pyautogui的单击功能,但是虽然将鼠标移到了正确的位置,但是实际的单击并没有发生,或者至少没有任何改变.

I try to use the click function of Pyautogui, but the actual click doesn't happen or at least there is no change at the page though it moves the mouse to the right place.

(我认为)该窗口处于焦点位置,因为该程序可与其他页面很好地配合使用.

The window is in focus (I think) because the program works well with other pages.

我只能找到一个相关的问题:在点击程序时遇到麻烦-pyautogui .但是,对此没有可接受的答案,我尝试了链接中的给定答案,但是没有用(它在python2中,但是我在python3中).

I could only find one relevant question: having trouble clicking in program - pyautogui. However, there was no accepted answer for that and I tried the given answer in the link but didn't work (It was in python2 but I'm in python3).

我使用Linux.我不知道为什么鼠标移到正确的位置却不执行点击.

I use Linux. I have no idea why the mouse moves to the right place but doesn't perform the click.

代码:

   from selenium import webdriver
   import pyautogui as py
   import time
   import pandas as pd
   browser=webdriver.Firefox()
   browser.maximize_window()
   browser.get("http://jao.eu/marketdata/dailyauctions")
   py.click(x=745,y=692, interval=1)

推荐答案

尝试如下

from selenium import webdriver
import pyautogui as py
import time
browser=webdriver.Chrome()
browser.maximize_window()
browser.get('http://jao.eu/marketdata/dailyauctions')
#Allows time for webpage to load
time.sleep(5)
#Set clicks parameter to 2
py.click(x=745,y=692, clicks=2, interval=1)

在click()函数中将clicks参数设置为2将使chrome浏览器刚刚打开活动窗口,第二次单击将单击click()函数中输入的坐标处的链接.

Setting the clicks parameter to 2 within the click() function will make the chrome browser just opened the active window and the second click will click the link at the coordinates entered in the click() function.

这篇关于为什么pyautogui点击不实际点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!