From: Patrick Keenan on
I'm trying to activate a (normally running) program that may not have focus,
and send keystrokes to it. Unfortunately I consistently get undesirable
behaviour with the code below -

if I use "AppActivate lnRet" the desired window is activated but there is a
delay of several seconds before anything else happens (the cursor shifts to
hourglass and flickers).

If I use "'AppActivate ("LiveNote FT")" I get " Runtime error 5 - Invalid
Procedure call or argument"

In either case, SendKeys gives a "Runtime Error 13 - Type Mismatch"

Naturally, there's more that is going to happen with these apps but this is
where it breaks down.
I expect that there's something obvious I'm missing but I just can't see it.

====
Private Sub LiveNoteTest_Click()
Dim lnRet
lnRet = Shell("C:\LIVENOTE\livenote.exe")
AppActivate lnRet
'AppActivate ("LiveNote FT")

' SendKeys "%T", "E"

End Sub
====

Thanks!
Patrick Keenan


From: Patrick Keenan on
- sorry, I'm using VB6 on WinXP and 2000.
-pk

"Patrick Keenan" <test(a)dev.null> wrote in message
news:I2GQe.1513$884.239049(a)news20.bellglobal.com...
> I'm trying to activate a (normally running) program that may not have
> focus, and send keystrokes to it. Unfortunately I consistently get
> undesirable behaviour with the code below -
>
> if I use "AppActivate lnRet" the desired window is activated but there is
> a delay of several seconds before anything else happens (the cursor shifts
> to hourglass and flickers).
>
> If I use "'AppActivate ("LiveNote FT")" I get " Runtime error 5 - Invalid
> Procedure call or argument"
>
> In either case, SendKeys gives a "Runtime Error 13 - Type Mismatch"
>
> Naturally, there's more that is going to happen with these apps but this
> is where it breaks down.
> I expect that there's something obvious I'm missing but I just can't see
> it.
>
> ====
> Private Sub LiveNoteTest_Click()
> Dim lnRet
> lnRet = Shell("C:\LIVENOTE\livenote.exe")
> AppActivate lnRet
> 'AppActivate ("LiveNote FT")
>
> ' SendKeys "%T", "E"
>
> End Sub
> ====
>
> Thanks!
> Patrick Keenan
>


From: Rick Rothstein [MVP - Visual Basic] on
> ' SendKeys "%T", "E"

The 2nd argument for the SendKeys function is optional; but if you
supply one, it needs to be a Boolean. You appear to be trying to send an
Alt+T followed by the letter "E" (without any attendant shifting key);
do that this way...

SendKeys "%TE"

If you wanted the Alt key to be "held down" for both keys, then do it
this way...

SendKeys "%(TE)"

You might want to look at the help files for the SendKeys statement; it
describes what I just posted and a lot more.

Rick


From: Test User on
"Rick Rothstein [MVP - Visual Basic]" <rickNOSPAMnews(a)NOSPAMcomcast.net>
wrote in message news:%23kzvCiLrFHA.3352(a)TK2MSFTNGP14.phx.gbl...
> > ' SendKeys "%T", "E"
>
> The 2nd argument for the SendKeys function is optional; but if you
> supply one, it needs to be a Boolean. You appear to be trying to send an
> Alt+T followed by the letter "E" (without any attendant shifting key);
> do that this way...
>
> SendKeys "%TE"
>
> If you wanted the Alt key to be "held down" for both keys, then do it
> this way...
>
> SendKeys "%(TE)"
>
> You might want to look at the help files for the SendKeys statement; it
> describes what I just posted and a lot more.
>
> Rick

Thanks! That seems to get rid of the error for the SendKeys -
unfortunately the AppActivate error is still blocking it, though; after a
delay of about 20 seconds I will get a "runtime error 5 - invalid procedure
call or argument". Have I missed something equally obvious there?

thanks again,
Patrick Keenan