Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending keypresses to another application

Status
Not open for further replies.

jumpjack

Programmer
Jul 28, 2006
79
IT
How can I have my application "simulating" pressing keys in another window?
I need to programmatically input my password into an application after I programmatically started it. How can I accomplish this task?


-- Jumpjack --
 
Try something along these lines;

AppActivate "MyOtherAppsCaption"
SendKeys "MyPassword~
 
I suggest you lookup VB6 help for the AppActivate and SendKeys keywords.

regards Hugh,
 
Actually I'm using VBA from within MS Access 97: is it the same?

-- Jumpjack --
 
VBA is not the same as VB6 and you should really be asking your question in forum707.

However VBA is in many respects similar to VB6 and does include the AppActivate and SendKeys commands. Look them up in VBA help.

regards Hugh
 
AppActivate and SendKeys work fine with calculator, but not with Lotus: AppActivate raises error "chiamata di routine o argomento non validi" (should sound like "invalid argument or procedure called"), both using a string or the result of Shell as paramater.
Why?
Other ideas?

-- Jumpjack --
 
Are you sure you are using the exact string displayed in the caption of the window you are trying to activate with AppActivate; I'm guessing that is 'Enter password'?

Another thought is that you are probably trying to AppActivate imeadiatley after the Shell has been used to run Lotus; in such a case Lotus may not have loaded sufficiently before the AppActivate command is encountered; try placing a time delay (to ensure Lotus has loaded fully) after the line including the Shell and before the one including the AppActivate and see if that helps.

You posted similar questions in thread707-1296412 back in Nov 06, I tried to help but you disappeared.

If you are trying to drive Lotus from a vb app I suggest a more reliable approach may be to automate it. You should be able to do that from the code supplied in thread707-1296412 (options are given there for cases when you do and do not know the password) and the link I made there to thread222-766157.

HTH Hugh
 
You posted similar questions in thread707-1296412 back in Nov 06, I tried to help but you disappeared.
Sorry, I lost that thread, this forum quite confuses me...

-- Jumpjack --
 
Are you sure you are using the exact string displayed in the caption of the window you are trying to activate with AppActivate; I'm guessing that is 'Enter password'?

Another thought is that you are probably trying to AppActivate imeadiatley after the Shell has been used to run Lotus; in such a case Lotus may not have loaded sufficiently before the AppActivate command is encountered; try placing a time delay (to ensure Lotus has loaded fully) after the line including the Shell and before the one including the AppActivate and see if that helps
I executed the code in debug mode, step by step, so at least one second passed between AppActivate and SendKeys.
And I tried both with "Enter Password" string and with main window caption.
I'm out of ideas; I'll get back to the FindWindow method for further tests.


-- Jumpjack --
 
<<so at least one second passed between AppActivate and SendKeys>>

Did you also step between the Shell and AppActivate as I originally suggested?
 
<<so at least one second passed between AppActivate and SendKeys>>


I'm confused - if AppActivate is raising an error how are you getting to SendKeys? Or has the error gone away?
 
Sorry, I lost that thread, this forum quite confuses me...
For future reference, one of the search options in this forum is search-by-handle: look yourself up!
 
<<I executed the code in debug mode, step by step, so at least one second passed between AppActivate and SendKeys.
And I tried both with "Enter Password" string and with main window caption.>>

As noted by Strongm it appears you are no longer getting an error on the AppActivate line.

1. So after that did you get an another error message? If so on what line?
2. Did the intended 'Enter password' (still assumed) window get highlighted?

Or What?
You must give us complete feedback on what is happening if you want us to help you.
 
AppActivate works if I pass path of C:\notes , does not if I pass the window title.
I'll be more precise as soon as I go back to office next monday...

-- Jumpjack --
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top