Skip to content

Instantly share code, notes, and snippets.

@silverbulletmdc
Created October 9, 2018 02:30
Show Gist options
  • Select an option

  • Save silverbulletmdc/268482de1d845ef16394d8b9137fc37f to your computer and use it in GitHub Desktop.

Select an option

Save silverbulletmdc/268482de1d845ef16394d8b9137fc37f to your computer and use it in GitHub Desktop.
#!/home/dechao_meng/anaconda3/bin/python
import time
import sys
import os
from selenium import webdriver
import pyperclip
recent_value = ""
chrome = webdriver.Chrome()
chrome.get("https://translate.google.com")
input_area = chrome.find_element_by_id('source')
while True:
tmp_value = pyperclip.paste()
if tmp_value != recent_value:
recent_value = tmp_value
print("Value changed: %s" % str(recent_value)[:20])
tmp_value = tmp_value.replace('\n', ' ')
input_area.clear()
input_area.send_keys(tmp_value)
time.sleep(0.1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment