The SetKeyboardState generated an error if the output is zero. If the output
is non-zero, there was no error. To get the error code, you have to call
GetLastError.
Why don't you use the keybd_event function? It is easier, and can also be
used to toggle NUM LOCK, CAPS LOCK, and SCROLL LOCK. It works very similar
to the mouse_event function.
Anyway, the GetKeyboardState returns an array of bytes. If a key is pressed,
the value returns 128 or 129, the least significant bit is to see if the
state has been changed. If the key is not pressed, the vlaue is 1 or 0.
You can also use the GetKeyState, to return information of only one key.
I have tried the WH_KEYBOARD_LL paramet
er in the keyboard hook, but the
callback function should return a pointer to a structure of information, but
all I get is nonsense. It does seem to react to keypresses of all windows.
Regards,
Wiebe.
"mnewett@blueyonder.co.uk"
wrote in message
news:506500000005000000F6E50000-1042324653000@exchange.ni.com...
> Wiebe, thanks for your advice. I'll forget that route then.
>
> I haven't tried the WH_KEYBOARD_LL function. I use Win98. I think this
> function is only available on Win2000 upwards.
>
> Have you much experience with the API command SetKeyboardState ?
>
> The output isn't returning an error so it should be working - but
> nothing is being typed.
>
> For lpKey Sate im using Type=Array, Data type=Unsigned 8-bit array,
> Array Format=Array Data Pointer.
>
> So the input to the API is a 1D numeric array. I am setting array
> elements to 1 where I want a key to be pressed, and 0 when not.
>
> Am I missing something ?