0

I am creating a program that can automate some tasks. But I am stuck up in between. I want to know any command with which I can put the same text entered by the user to another window. For Example:

import web browser as wb
a = input("Enter your text...")
wb.open("www.xyz.com")

Here, I want to ask the user to input text and then I want to open any website like google or any notes website and I want to put the same input entered by the user (whose variable has been defined as 'a') into the text box. So how can I do it?

Is there any specific function?

I tried Xerox and pyperclip as copy and paste but it is not working it's just copying and not pasting... So is there any other function or module or am I doing any mistake in paperclip or Xerox to paste the data?

Please guide as soon as possible.

1 Answers1

1

you can use selenium module

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

search_item = input("enter your text...")

driver = webdriver.Chrome()

driver.get("https://www.google.com")
search = driver.find_element_by_name('q')
search.send_keys(search_item)
search.send_keys(Keys.RETURN)
just a stranger
  • 310
  • 1
  • 4
  • 13
  • yaa I got it. But it is only for google, right? if I want to put the same text as user into WhatsApp web or other social media then what do I need to do? – Harsh Master Mar 12 '21 at 15:57
  • sure you can,If the site you're using is a site that requires a login (like social media platforms),there are two ways in front of it.first,You open the site you previously logged in with python selenium,save the cookies, and use it again later. Another solution is to enter user information every time he enters the site. See these [question](https://stackoverflow.com/questions/15058462/how-to-save-and-load-cookies-using-python-selenium-webdriver) for more information. After logging into the site, all you have to do is to examine the correct html codes and create a system like the answer above. – just a stranger Mar 12 '21 at 17:20