'Using pyautogui, how can I get Python to press Ctrl + F to find a word on a webpage? Prefer not to use Selenium or manually hit Ctrl+F
I've tried:
pyautogui.hold(["ctrl"]) pyautogui.press("f")
Sure, Selenium might work, but I like using Vivaldi as my browser, and I want to figure out how to accomplish Ctrl+F with the current setup.
Solution 1:[1]
You should use the 'hotkey' function instead. It should look something like this:
pyautogui.hotkey('ctrl', 'f')
Solution 2:[2]
You can use Keyboard Control Functions documentation for that, using pyautogui
functions.
In order to find something in the browser using the keys CTRL
+ F
you can use the following commands:
import pyautogui
# You can define what you want to search
find = 'google'
# Use keys below
pyautogui.hotkey('ctrl', 'f')
# Write what you want
pyautogui.write(find, interval=0.05)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | winston1420 |
Solution 2 | Guilherme Matheus |