0

So the start of my program opens up a web page and then clicks on it. This is my code. It opens up the page fine, but doesn't click. I tried to make it move the mouse first, and the mouse moves exactly where I want but doesn't click. I have the sleep function there so web page has time to load before the click happens.

Any help would be appreciated.

import webbrowser
import pyautogui
#Open Website
webbrowser.open('https://www.midomi.com/index.php?action=m\
ain.track&track_id=100712805442046374&from=voice_search')
#Have it record audio
pyautogui.moveTo(659,99)
time.sleep(5)
pyautogui.click(659, 99)
  • Maybe add an identical, second call to click() immediately following (it might just be that you have to select the opened browser window as the current window) – Thomas Jul 16 '20 at 00:54

1 Answers1

0

You should first try importing the time module that you're trying to use and see if it works with that.

import webbrowser
import pyautogui
import time
# Open Website
webbrowser.open('https://www.midomi.com/index.php?action=m\
ain.track&track_id=100712805442046374&from=voice_search')
# Have it record audio
pyautogui.moveTo(659, 99)
time.sleep(5)
pyautogui.click(659, 99)

Also you shouldn't need to specify the coordinates for the click since you are already moving the mouse to that position. Removing the moveTo() function should still work the same, or just remove the cords from the click function.

import webbrowser
import pyautogui
import time
# Open Website
webbrowser.open('https://www.midomi.com/index.php?action=m\
ain.track&track_id=100712805442046374&from=voice_search')
# Have it record audio
time.sleep(5)
pyautogui.click(659, 99)
Brian Gee
  • 11
  • 3