Keyboard Hooking

I have implemented keyboard hooking using the user32 API - the problem that I'm having is that every key pressed is generating 2 call backs - I can make it work for regular keystrokes by having the chr(Vk_code) - where flags = 0 - that way I don't miss any keys strokes-- the problem that I'm having is that command keys such as back space - are doubled that way -

I have a sub that checks the getAsyncKeyState of the command keys similar to the following:

sub CheckControls(byval VK_code as integer, byval flags as integer)
if getAsyncKeyState(VK_BKSPACE) then
CHAR_BUFFER(1) = iif(flags = 0,chr(vk_code),"")
end if
end sub

the problem is the output is as follows if I hit backspace "{{BS}"

{ is the char representation of the vk_code value of Backspace - this is not ideal -- if I change the flags = 0 to flags <> 0 then this corrects the issue - however with that setting if the input is typed to fast then keys are missed whereas if flag = 0 is used you won't miss any key strokes.

I can provide more code if requested - I'm not very familiar with Hooks so I'm sorry if this is not clear.

Thanks in advance for your help.

C:Dos Run
Run Dos Run


  • No worries, I found a way around it by checking against whether the shift key was active + the vk_keycode

    Thanks for looking anyways.
    C:Dos Run
    Run Dos Run
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion