imitating user input

G

Greg Grin

I need to imitate keyboard strokes in an active window inside of
internet explorer, specifically I need my program to log on to a
chatroom without me actually sitting in front of my computer. Also,
once it has logged on to the program I need my program to "read"
(search for strings, etc.) the text that's entered by other users in
this "chatroom". The problem I have is actually logging in to the
chatroom since I have not found a way to duplicate keyboard strokes.


If someone could point me in the right direction on tutorials about
this or show me a sample program that does this I would really
appreciate it.


--grigri9

P.S. I am a first semester programming student at my high school and
Python is the only language I know.
 
T

Terry Reedy

Greg Grin said:
I need to imitate keyboard strokes in an active window inside of
internet explorer, specifically I need my program to log on to a
chatroom without me actually sitting in front of my computer. Also,
once it has logged on to the program I need my program to "read"
(search for strings, etc.) the text that's entered by other users in
this "chatroom". The problem I have is actually logging in to the
chatroom since I have not found a way to duplicate keyboard strokes.

For this problem, you do *not* need to imitate keystrokes (and mouseclicks)
in the way that you would for interacting with a local interactive program.
You *do* need to send and receive strings through internet sockets
according to the Internet Relay Chat protocol (assuming that that is the
protocol used by the site you are interested in. There are existing chat
programs that can be scripted in Python. The Python-coded Twisted package
also includes an IRC implementation. Some of the other internet packages
may also.

Look at
http://twistedmatrix.com/users/jh/teud/Twisted/twisted.protocols.irc.html
or google Python Internet Relay Chat protocol, as I did, for more.

Terry J. Reedy
 
M

Miki Tebeka

Hello Greg,
I need to imitate keyboard strokes in an active window inside of
internet explorer, specifically I need my program to log on to a
chatroom without me actually sitting in front of my computer. Also,
once it has logged on to the program I need my program to "read"
(search for strings, etc.) the text that's entered by other users in
this "chatroom". The problem I have is actually logging in to the
chatroom since I have not found a way to duplicate keyboard strokes.
I agree with the other response, however if you're interested in
generating key strokes anyhow have a look at AutoIt
(http://www.hiddensoft.com/AutoIt/). You can use either the executable
by generating scripts or the ActiveX component (or even the dll with
ctypes).

HTH.
Miki
 
S

SimonVC

Try This:

Rob Marchetti: Pamie [Pamie allows you to write Python scripts in
order to drive Internet Explorer. Pamie is a lite Python port of SAMIE
written in Perl by Henry Wasserman. This is a "free" open-source tool
written for QA engineers or developers as a means to simulate users
exploring a web site. ]

http://pamie.sourceforge.net/
 
C

calfdog

Greg,

There are lots of ways to do this. Pamie is just one method.
basically you want to set the value of a two textboxes and submit the
form.

If you have an instance of the browse you can access it's methods and
attributes.

In Python you could do it this way:

#Instantiate a new instance of the IE browser:
ieBrowser = DispatchEx('InternetExplorer.Application')

Now you have access to the textboxes and it's buttons
Since you have and instance of the browser ieBrowser you can begin:

For example a simple login page with username textbox, password
textbox and submit button.

ieBrowser.Document.forms[0].elements.all[username].value =
"YourUsername"
ieBrowser.Document.forms[0].elements.all[password ].value =
"YourPassword"
ieBrowser.Document.forms[0].elements.all[SubmitButtonName].form.submit()

You can get the actual names for your username, password and
SubmitButtonName from viewing the source of the Webpage and doing a
find on the word "input"

You can do the above in Perl VB ruby etc.. although the syntax may be
a little different.

Hope this helps.

Enjoy

RLM
Pamie creator




For more information:
http://msdn.microsoft.com/library/d...hor/dhtml/reference/dhtml_reference_entry.asp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top