LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Simulate pressing mouse button

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 ?
0 Kudos
Message 11 of 13
(1,495 Views)
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 ?
0 Kudos
Message 12 of 13
(1,495 Views)
Hi Wiebe. Thanks for your continued help.

I've got the GetKeyboardState working fine. I'm replacing the numeric output array with a boolean array. If numeric value of a virtual key >1 then Boolean state = True. If numeric value of a virtual key = 0 or 1, then Boolean state = False.

This way I have a neat T/ F boolean array.

I did use the keyboard event function originally - but because I had to execute the function for each virtual key (255 times total) the execution speed was extremely poor. Thats why I wanted to use the SetKeyboardState.

I've attached the SetKeyboardState VI that I was working on. To prove the VI, when run move mouse
inside string control and press mouse button. It should then continue to input "a" inside string control - but it doesnt work.

What do you do by the way? NI support were unable to help me with the API problems.

Any help greatly appreciated as always

Mike
0 Kudos
Message 13 of 13
(1,495 Views)