00:00
00:00
Newgrounds Background Image Theme

GrawlixMan just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

How to make Python type text

1,305 Views | 4 Replies
New Topic Respond to this Topic

How to make Python type text 2014-08-28 22:31:17


I honestly have no idea how to start with this one.

I'd like to write a Python program that will type text into a text field on a website. I'd like to be able to customize the speed at which it does this. (don't want it just dumping the whole text into the field)

Is there some library for this type of functionality.


∀x (∃e (e ∈ x ∧ ∀x ¬(x ∈ e)) ∨ ∃y ¬∃e (e ∈ x ∧ ¬∃z (z ∈ y ∧ z ∈ e ∧ ∀x ¬((x ∈ y ∧ x ∈ e) ∧ ¬(x = z)))))

Response to How to make Python type text 2014-09-04 05:46:39


Anyone?


∀x (∃e (e ∈ x ∧ ∀x ¬(x ∈ e)) ∨ ∃y ¬∃e (e ∈ x ∧ ¬∃z (z ∈ y ∧ z ∈ e ∧ ∀x ¬((x ∈ y ∧ x ∈ e) ∧ ¬(x = z)))))

Response to How to make Python type text 2014-09-04 18:18:00


At 9/4/14 05:46 AM, sharpnova wrote: Anyone?

I think Selenium might be your solution. I haven't messed around with it too much, but by using the "send_keys()" method to an element on the web page you could probably set up a timer script to dictate how fast send_keys is called.

Here's a modified example from one of their own examples.

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

browser = webdriver.Firefox()

browser.get('http://www.yahoo.com')
assert 'Yahoo!' in browser.title
elem = browser.find_element_by_name('p')  # Find the search box

string = "Characters you want to send"
for c in string:
    elem.send_keys(c)
    time.sleep(1)

elem.send_keys(Keys.RETURN)   # Submit the form
browser.quit()

BBS Signature

Response to How to make Python type text 2014-09-04 18:24:03


At 9/4/14 06:18 PM, coln wrote: time.sleep(1)

Apparently Selenium has its own set_speed function that dictates how fast operations are carried out. With more research I have no doubt you could find a better way of doing it that what I posted above, haha.


BBS Signature

Response to How to make Python type text 2014-09-04 19:40:33


At 9/4/14 06:18 PM, coln wrote: I think Selenium might be your solution.

Hey that looks perfect I think. I'm out of town and not able to check on it right now but I'll be back for the weekend and play with it.

Thanks a lot. I could not find this or anything like this despite so much googling. I think the forms my queries tend to take are inefficient.


∀x (∃e (e ∈ x ∧ ∀x ¬(x ∈ e)) ∨ ∃y ¬∃e (e ∈ x ∧ ¬∃z (z ∈ y ∧ z ∈ e ∧ ∀x ¬((x ∈ y ∧ x ∈ e) ∧ ¬(x = z)))))