Home All Groups Group Topic Archive Search About

SendKeys command fails on Vista

Author
27 Feb 2007 11:19 PM
Hansin
Hi everyone.

I have a compiled VB6 app that seems to work ok when installed on Windows
Vista except for one thing.

Whenever I use the SENDKEYS command to send a key stroke an error occurs
along the lines of "No Permission" to do that.

I am stumped as to why a harmless thing like the SENDKEYS command should
cause a problem to Vista.

Any ideas anyone.

Author
28 Feb 2007 9:19 AM
Jan Hyde
"Hansin" <han***@btinternet.com>'s wild thoughts were
released on Tue, 27 Feb 2007 23:19:02 -0000 bearing the
following fruit:

>Hi everyone.
>
>I have a compiled VB6 app that seems to work ok when installed on Windows
>Vista except for one thing.
>
>Whenever I use the SENDKEYS command to send a key stroke an error occurs
>along the lines of "No Permission" to do that.
>
>I am stumped as to why a harmless thing like the SENDKEYS command should
>cause a problem to Vista.

It's not harmless though.

>Any ideas anyone.

Sendkeys allows you to send keystrokes to any window - an
obvious security risk.

I found I could replace all our applications SendKeys calls
with something else anyway.
Author
28 Feb 2007 12:24 PM
Mike Williams
"Jan Hyde" <StellaDrin***@REMOVE.ME.uboot.com> wrote in message
news:h1iau2ltg2prgm56sucko5gttr7ru3lfbu@4ax.com...

> Sendkeys allows you to send keystrokes to any window
> - an obvious security risk. I found I could replace all our
> applications SendKeys calls with something else anyway.

Is the fact that you're not telling the OP how you did it a security feature
as well?

Mike
Author
28 Feb 2007 12:43 PM
Jan Hyde
"Mike Williams" <M***@WhiskyAndCoke.com>'s wild thoughts
were released on Wed, 28 Feb 2007 12:24:15 -0000 bearing the
following fruit:

>"Jan Hyde" <StellaDrin***@REMOVE.ME.uboot.com> wrote in message
>news:h1iau2ltg2prgm56sucko5gttr7ru3lfbu@4ax.com...
>
>> Sendkeys allows you to send keystrokes to any window
>> - an obvious security risk. I found I could replace all our
>> applications SendKeys calls with something else anyway.
>
>Is the fact that you're not telling the OP how you did it a security feature
>as well?

No, which solution I used depends on what SendKeys is being
used for.

I found a lot of the uses of SendKeys were in old code and
could easily be replaced with normal VB code, others were a
bit more tricky.

The OP would have to post again with any situations (s)he
needs help with.
Author
28 Feb 2007 12:22 PM
Mike Williams
"Hansin" <han***@btinternet.com> wrote in message
news:jsKdnVW6z56oIXnYRVnytgA@bt.com...
> Hi everyone.
>
> I have a compiled VB6 app that seems to work ok when installed
> on Windows Vista except for one thing. Whenever I use the
> SENDKEYS command to send a key stroke an error occurs along the lines of
> "No Permission" to do that. I am stumped as
> to why a harmless thing like the SENDKEYS command . . .

It is not harmless. In fact it can be very harmful! And, for that reason, it
is probably falling foul of the new Vista security features. You might have
better luck using the Keybd_Event API instead, unless that is bolted down
too (I haven't got time at the moment to swap to my Vista setup to check).
It's worth looking at though.

Mike
Author
28 Feb 2007 12:47 PM
Jan Hyde
"Mike Williams" <M***@WhiskyAndCoke.com>'s wild thoughts
were released on Wed, 28 Feb 2007 12:22:54 -0000 bearing the
following fruit:

Show quoteHide quote
>"Hansin" <han***@btinternet.com> wrote in message
>news:jsKdnVW6z56oIXnYRVnytgA@bt.com...
>> Hi everyone.
>>
>> I have a compiled VB6 app that seems to work ok when installed
>> on Windows Vista except for one thing. Whenever I use the
>> SENDKEYS command to send a key stroke an error occurs along the lines of
>> "No Permission" to do that. I am stumped as
>> to why a harmless thing like the SENDKEYS command . . .
>
>It is not harmless. In fact it can be very harmful! And, for that reason, it
>is probably falling foul of the new Vista security features. You might have
>better luck using the Keybd_Event API instead, unless that is bolted down
>too (I haven't got time at the moment to swap to my Vista setup to check).
>It's worth looking at though.
>
>Mike
>

The PostMessage API can be used under vista. Perhaps the
fact you have to specify the hwnd of the windows makes a
difference <shrug>
Author
28 Feb 2007 2:33 PM
J French
On Wed, 28 Feb 2007 12:47:17 +0000, Jan Hyde
<StellaDrin***@REMOVE.ME.uboot.com> wrote:

<snip>

>The PostMessage API can be used under vista. Perhaps the
>fact you have to specify the hwnd of the windows makes a
>difference <shrug>

Surely, with SendKeys it goes to GetForegroundWindow

I must confess that I consider SendKeys a bit .. well naff
Author
28 Feb 2007 8:52 PM
Rick Rothstein (MVP - VB)
"Mike Williams" <M***@WhiskyAndCoke.com> wrote in message
news:eIBaoMzWHHA.3980@TK2MSFTNGP02.phx.gbl...
> You might have better luck using the Keybd_Event API instead,

Apparently...

http://m8software.com/developer/keysend/sendkey.htm

Rick
Author
28 Feb 2007 1:29 PM
Mike Williams
"Hansin" <han***@btinternet.com> wrote in message
news:jsKdnVW6z56oIXnYRVnytgA@bt.com...

> Whenever I use the SENDKEYS command [in Vista] to
> send a key stroke an error occurs long the lines of "No
> Permission" to do that.

Further to my previous response about the security features of Vista, I've
just fired up Vista (Vista Ultimate full version, not a beta) and from a few
tests with a small VB test program the SendKeys function seems to work fine.
I've tried it on the main Admin account and on a standard User account and
on the Guest account, and it works fine on all of them (and so does the
KeyBd_Event API). I haven't used Vista for more than a few hours on and off,
so I've had no time to delve into its various security features, but I
wonder why SendKeys is working fine on my own vanilla Vista Ultimate setup,
under all three different kinds of account?

Mike
Author
28 Feb 2007 4:42 PM
Jan Hyde
"Mike Williams" <m***@whiskyandCoke.com>'s wild thoughts
were released on Wed, 28 Feb 2007 13:29:45 -0000 bearing the
following fruit:

Show quoteHide quote
>"Hansin" <han***@btinternet.com> wrote in message
>news:jsKdnVW6z56oIXnYRVnytgA@bt.com...
>
>> Whenever I use the SENDKEYS command [in Vista] to
>> send a key stroke an error occurs long the lines of "No
>> Permission" to do that.
>
>Further to my previous response about the security features of Vista, I've
>just fired up Vista (Vista Ultimate full version, not a beta) and from a few
>tests with a small VB test program the SendKeys function seems to work fine.
>I've tried it on the main Admin account and on a standard User account and
>on the Guest account, and it works fine on all of them (and so does the
>KeyBd_Event API). I haven't used Vista for more than a few hours on and off,
>so I've had no time to delve into its various security features, but I
>wonder why SendKeys is working fine on my own vanilla Vista Ultimate setup,
>under all three different kinds of account?

try

Call SendKeys("{TAB}")

with UAC on

You should get a 'permission denied' error.
Author
28 Feb 2007 1:49 PM
Paul Clement
On Tue, 27 Feb 2007 23:19:02 -0000, "Hansin" <han***@btinternet.com> wrote:

¤ Hi everyone.
¤
¤ I have a compiled VB6 app that seems to work ok when installed on Windows
¤ Vista except for one thing.
¤
¤ Whenever I use the SENDKEYS command to send a key stroke an error occurs
¤ along the lines of "No Permission" to do that.
¤
¤ I am stumped as to why a harmless thing like the SENDKEYS command should
¤ cause a problem to Vista.
¤
¤ Any ideas anyone.

My understanding is that SendKeys should function properly under VB 6.0 but not 5.0.

As an alternative you should be able to use the SendInput and CopyMemory API function calls:

http://allapi.mentalis.org/apilist/SendInput.shtml


Paul
~~~~
Microsoft MVP (Visual Basic)
Author
28 Feb 2007 5:57 PM
Karl E. Peterson
Paul Clement <UseAdddressAtEndofMess***@swspectrum.com> wrote:
> ¤ I am stumped as to why a harmless thing like the SENDKEYS command should
> ¤ cause a problem to Vista.
> ¤
> ¤ Any ideas anyone.
>
> My understanding is that SendKeys should function properly under VB 6.0 but not
> 5.0.

How'd you come to that understanding?  Any basis for it, that you'd care to share?
--
..NET: It's About Trust!
http://vfred.mvps.org
Author
28 Feb 2007 8:42 PM
Paul Clement
On Wed, 28 Feb 2007 09:57:59 -0800, "Karl E. Peterson" <k***@mvps.org> wrote:

¤ Paul Clement <UseAdddressAtEndofMess***@swspectrum.com> wrote:
¤ > ¤ I am stumped as to why a harmless thing like the SENDKEYS command should
¤ > ¤ cause a problem to Vista.
¤ > ¤
¤ > ¤ Any ideas anyone.
¤ >
¤ > My understanding is that SendKeys should function properly under VB 6.0 but not
¤ > 5.0.
¤
¤ How'd you come to that understanding?  Any basis for it, that you'd care to share?

Someone else had described that experience. I can't confirm it since I do not have Visual Basic 5.0
installed.


Paul
~~~~
Microsoft MVP (Visual Basic)
Author
28 Feb 2007 8:48 PM
Karl E. Peterson
Paul Clement <UseAdddressAtEndofMess***@swspectrum.com> wrote:
Show quoteHide quote
> On Wed, 28 Feb 2007 09:57:59 -0800, "Karl E. Peterson" <k***@mvps.org> wrote:
>
> ¤ Paul Clement <UseAdddressAtEndofMess***@swspectrum.com> wrote:
> ¤ > ¤ I am stumped as to why a harmless thing like the SENDKEYS command should
> ¤ > ¤ cause a problem to Vista.
> ¤ > ¤
> ¤ > ¤ Any ideas anyone.
> ¤ >
> ¤ > My understanding is that SendKeys should function properly under VB 6.0 but
> not
> ¤ > 5.0.
> ¤
> ¤ How'd you come to that understanding?  Any basis for it, that you'd care to
> share?
>
> Someone else had described that experience. I can't confirm it since I do not
> have Visual Basic 5.0 installed.

I was just curious.  I wonder if it's because of something as silly as the runtime
not shipping with Vista?  I only built a Vista VM the other day, and haven't played
much myself.  (I frankly can't get past the laughter, to actually take that POS
seriously.)
--
..NET: It's About Trust!
http://vfred.mvps.org