alternative or replacement for SendKeys

  • Thread starter Thread starter titan nyquist
  • Start date Start date
T

titan nyquist

SendKeys seems to have security problems in IE7 and still does not
work well in Firefox. Is there a replacement for it?

I'm interested in any solution... even p/invoke to allow usage of
commands in user32.dll...

~titan
 
Titan,

What do you mean by "allow usage of commands in user32.dll".

Why not automate the browsers through their respective interfaces (I
don't know if firefox allows for manipulation out-of-process, but I imagine
that it does).
 
What do you mean by "allow usage of commands in user32.dll".

I mean, I could use "SendMessage" in user32.dll for example, via p/
invoke:
http://www.pinvoke.net/default.aspx/user32/SendMessage.html
Why not automate the browsers through their respective interfaces (I
don't know if firefox allows for manipulation out-of-process, but I imagine
that it does).

Could you elaborate on this? Give me an example function so I can
think of this on the same page you are on? Thanks!

~titan
 
titan nyquist said:
SendKeys seems to have security problems in IE7 and still does not
work well in Firefox. Is there a replacement for it?

I'm interested in any solution... even p/invoke to allow usage of
commands in user32.dll...

SendInput is the Win32 function for simulating keypresses, or if you need
backward compatibility to really old Windows versions, use keybd_event.

keybd_event is actually the easiest, but since you send keys one by one then
keypresses can get mixed up.

SendMessage(WM_CHAR) may also be an option if you know what window you want
to send keys to and don't want to mess with focus.
 
Titan,

Google "automate internet explorer" and you should get a number of
examples. They are not all in .NET, but could easily be done using .NET
technologies and COM interop.

As for FireFox, you might have to dig a little deeper for that.

What ^exactly^ are you trying to do here? You mention security issues
when trying to send messages to another window. Of course, IE is doing what
it is supposed to do in not processing them. If you elaborate on what the
end result you are trying to achieve is, an alternative could be suggested.
 
Google "automate internet explorer"

I have, and it looks like you are suggesting that, INSTEAD of
launching a browser that will be controlled by my app, to create an
internal (IE?) web browser inside my app that acts as if a human is
controlling a legitimate one. Is this right? I have tried this, with
some success, but some of my navigation actions seem to be blocked by
security issues (the website i am accessing somehow "knows" that I am
not a surfer because I am not duplicating the browsing accurately
enough. I'll elaborate on this if you wish.
What ^exactly^ are you trying to do here?

I am trying to control the browser from my app... so that my app can
take the place of a human to do mundane tasks repeatedly. Basically,
I just want to send key presses (characters, tabs, enter) to the
browser.
You mention security issues
when trying to send messages to another window. Of course, IE is doing what
it is supposed to do in not processing them. If you elaborate on what the
end result you are trying to achieve is, an alternative could be suggested.

SendKeys has problems with duplication with IE due to security issues
(which I can guess arise because why would a secure system ever allow
one app to control another app???) It's explain well here:
http://blogs.msdn.com/michkap/archive/2006/06/10/625285.aspx

"As many developers have found, the current incarnation [of SendKeys]
in both VB and in .NET does really strange things in beta builds of
IE7 (character duplication, etc.) and actual exceptions in beta builds
of Vista due to some of the security changes in the OS."
 
I am trying to control the browser from my app... so that my app can
take the place of a human to do mundane tasks repeatedly. Basically,
I just want to send key presses (characters, tabs, enter) to the
browser.

In many cases, what you are describing can be done without ever using
SendKeys, or even IE 7. For example, we do something similar with WebRequest
and HttpWebResponse classes. Whether this fits your bill is for you to
decide.

How are your processes to work when the screen saver kicks in? How are you
ensuring IE 7 (and the correct instance) gets the results of the SendKeys?
 

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

Back
Top