Any alternative to SendKeys?

  • Thread starter Thread starter Pete
  • Start date Start date
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.
 
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.
 
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
 
Pete

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

....Ashok
 
Back
Top