From: Boris Pauljev on
I'm trying to test the keyboard input for the LLKHF_INJECTED flag.

I got this from a forum:
>>>>
It means the flags member is a bitmasked value so you can extract usable
information by hit-testing it against predefined masks:

Private Const LLKHF_EXTENDED = &H1
Private Const LLKHF_INJECTED = &H10
Private Const LLKHF_ALTDOWN = &H20
Private Const LLKHF_UP = &H80

If struct.flags And LLKHF_EXTENDED Then 'An extended key
If struct.flags And LLKHF_INJECTED Then 'An injected key
<<<<

This is generally clear to me, however I don't know if the author's
"struct.flags And LLKHF_INJECTED" is really correct.

When I insert a key by pressing down the key manually on the keyboard,
struct.flags is 0.
When I insert a key with e. g. the Microsoft on-screen keyboard,
struct.flags is 16.

So if I tested it as the author above did, LLKHF_INJECTED would never be
true.

Am I wrong?

Boris
From: Henning on

"Boris Pauljev" <nordiccoder(a)hotmail.com> skrev i meddelandet
news:u9LYaIAxKHA.6140(a)TK2MSFTNGP05.phx.gbl...
> I'm trying to test the keyboard input for the LLKHF_INJECTED flag.
>
> I got this from a forum:
> >>>>
> It means the flags member is a bitmasked value so you can extract usable
> information by hit-testing it against predefined masks:
>
> Private Const LLKHF_EXTENDED = &H1
> Private Const LLKHF_INJECTED = &H10
> Private Const LLKHF_ALTDOWN = &H20
> Private Const LLKHF_UP = &H80
>
> If struct.flags And LLKHF_EXTENDED Then 'An extended key
> If struct.flags And LLKHF_INJECTED Then 'An injected key
> <<<<
>
> This is generally clear to me, however I don't know if the author's
> "struct.flags And LLKHF_INJECTED" is really correct.
>
> When I insert a key by pressing down the key manually on the keyboard,
> struct.flags is 0.
> When I insert a key with e. g. the Microsoft on-screen keyboard,
> struct.flags is 16.
>
> So if I tested it as the author above did, LLKHF_INJECTED would never be
> true.
>
> Am I wrong?
>
> Boris

Yes, &H10 = 16 decimal. You have to AND with the const and check for a
nonzero result.

/Henning


From: Henning on

"Henning" <computer_hero(a)coldmail.com> skrev i meddelandet
news:ey78ELDxKHA.732(a)TK2MSFTNGP06.phx.gbl...
>
> "Boris Pauljev" <nordiccoder(a)hotmail.com> skrev i meddelandet
> news:u9LYaIAxKHA.6140(a)TK2MSFTNGP05.phx.gbl...
>> I'm trying to test the keyboard input for the LLKHF_INJECTED flag.
>>
>> I got this from a forum:
>> >>>>
>> It means the flags member is a bitmasked value so you can extract usable
>> information by hit-testing it against predefined masks:
>>
>> Private Const LLKHF_EXTENDED = &H1
>> Private Const LLKHF_INJECTED = &H10
>> Private Const LLKHF_ALTDOWN = &H20
>> Private Const LLKHF_UP = &H80
>>
>> If struct.flags And LLKHF_EXTENDED Then 'An extended key
>> If struct.flags And LLKHF_INJECTED Then 'An injected key
>> <<<<
>>
>> This is generally clear to me, however I don't know if the author's
>> "struct.flags And LLKHF_INJECTED" is really correct.
>>
>> When I insert a key by pressing down the key manually on the keyboard,
>> struct.flags is 0.
>> When I insert a key with e. g. the Microsoft on-screen keyboard,
>> struct.flags is 16.
>>
>> So if I tested it as the author above did, LLKHF_INJECTED would never be
>> true.
>>
>> Am I wrong?
>>
>> Boris
>
> Yes, &H10 = 16 decimal. You have to AND with the const and check for a
> nonzero result.
>
> /Henning
>
>
You can test using:
If (struct.flags And LLKHF_INJECTED) > 0 Then 'An injected key

/Henning


From: Nobody on
"Henning" <computer_hero(a)coldmail.com> wrote in message
news:edXiI$PxKHA.3564(a)TK2MSFTNGP05.phx.gbl...
> You can test using:
> If (struct.flags And LLKHF_INJECTED) > 0 Then 'An injected key
>
> /Henning

It's preferable to use "<> 0" or "= 0". If the flag was &H80000000, which is
a negative number, the result would be negative in the above statement.


From: Henning on

"Nobody" <nobody(a)nobody.com> skrev i meddelandet
news:O35gNDQxKHA.1548(a)TK2MSFTNGP02.phx.gbl...
> "Henning" <computer_hero(a)coldmail.com> wrote in message
> news:edXiI$PxKHA.3564(a)TK2MSFTNGP05.phx.gbl...
>> You can test using:
>> If (struct.flags And LLKHF_INJECTED) > 0 Then 'An injected key
>>
>> /Henning
>
> It's preferable to use "<> 0" or "= 0". If the flag was &H80000000, which
> is a negative number, the result would be negative in the above statement.
>
>

In general thats correct, I was not concidering values other than presented.

/Henning