Any alternative to SendKeys?

P

Pete

I'm trying to use SendKeys to send a 'close' key sequence
to an application popup. Unfortunately, I'm running into
the classic timing issues with SendKeys at it sometimes
hits the wrong app (even though I'm using AppActivate).

Is there a more intelligent way of sending keystrokes to a
specifies window, maybe using the class id instaed of the
window text or seomthing similar?

Thanks for your help.
 
A

Armin Zingler

Pete said:
I'm trying to use SendKeys to send a 'close' key sequence
to an application popup. Unfortunately, I'm running into
the classic timing issues with SendKeys at it sometimes
hits the wrong app (even though I'm using AppActivate).

Is there a more intelligent way of sending keystrokes to a
specifies window, maybe using the class id instaed of the
window text or seomthing similar?

Thanks for your help.

The only reliable way is using the application's COM automation model, if
available.
 
R

Russell Jones

Send the application a close message instead. You imply that you're
launching the application, so you should have a Process object that you can
use to close the application. Depending on what the application does, you
may be able to redirect the process input to send commands.

If that's not possible, because you need the popup to perform some sequence
such as saving a file that occurs only via the close key-sequence, then use
SendKeys in a loop, checking to make sure that the popup application is the
active window before sending each keystroke.

This article may help:
http://www.devx.com/dotnet/Article/7914/0/page/1
 
G

G.Ashok

Pete

You can use the SendMessage (WinAPI) to send the keys to active Application
(i.e your application)

....Ashok
 

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

Top