For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > August 2005 > AppActivate and SendKeys question









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author AppActivate and SendKeys question
Patrick Keenan

2005-08-29, 6:55 pm

Xref: TK2MSFTNGP08.phx.gbl microsoft.public.vb.general.discussion:563027

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


Patrick Keenan

2005-08-29, 6:55 pm

- sorry, I'm using VB6 on WinXP and 2000.
-pk

"Patrick Keenan" <test@dev.null> wrote in message
news:I2GQe.1513$884.239049@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
>



Rick Rothstein [MVP - Visual Basic]

2005-08-29, 6:55 pm

> ' 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


Test User

2005-08-29, 6:55 pm

"Rick Rothstein [MVP - Visual Basic]" <rickNOSPAMnews@NOSPAMcomcast.net>
wrote in message news:%23kzvCiLrFHA.3352@TK2MSFTNGP14.phx.gbl...
>
> 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


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com