I can't figure out how to test what key has been hit in my keyboardproc hook. Here is a code snippet from my program:

KeyboardProc PROC code:DWORD,wParam:WPARAM,lParam:LPARAM
mov eax,code
.IF eax==HC_ACTION
mov eax,lParam
shr eax,16
and eax,0FFh
.IF eax==VK_TAB
invoke SendMessage,hWnd,WM_DESTROY,NULL,NULL
ret
.ELSE
invoke CallNextHookEx,hHook,code,wParam,lParam
push eax
ret
.ENDIF
.ELSE
invoke CallNextHookEx,hHook,code,wParam,lParam
push eax
.ENDIF
ret
KeyboardProc endp

I want the program to exit if the tab key is pressed but it never does, which implies that eax never equals 09h (VK_TAB). I have tested this with many other virtual key codes and I can't seem to get it to work with any button. Am I testing the wrong byte from lParam?
Posted on 2001-10-08 21:30:45 by Cintrifical
i think wParam is the keycode...try that.
Posted on 2001-10-08 22:45:26 by Sloat
Do you use any debugger?
if you use SoftIce just put a 'INT 3' instruction somewhere inside the code you want to debug and then in SoftIce do a 'BPINT 3'.
Assemble, link and trace your way to happiness :)

If you don't use a debugger, then USE one. It's the coder's best companion. Like dogs to human beings :)

Latigo
Posted on 2001-10-08 23:15:02 by latigo
Yeah, Sloat is right, the wParam is the one that holds the key, but anyway, here you have a working source that does exactly what ur searching for...


Good Luck !! :grin:

-MagicMac. :alright:
Posted on 2001-10-08 23:46:31 by magicmac
Thanks for all your help! And thanks for the sample program, it clears up many of my questions!
Posted on 2001-10-09 16:11:24 by Cintrifical
You're welcome man, by the way, I'm coding a HotKey Macro Program that deals a lot with the KeyBoard and Codes and Virtual Keys and everything, if you want that one, just go to this thread F-Macros Download and download the FMacros.zip that's with the full source included... :)




Good Luck !! :alright:



-MagicMac.:tongue:
Posted on 2001-10-09 20:20:20 by magicmac
That's a very interesting little program. Very nice indeed! I've been going over it and have learned a lot already.

Another question has come to mind as I experiment with system hooks. Is it possible to disable alt+tab, ctrl+esc, or ctrl+alt+del with a keyboard hook? I think I am going to give it a try but I don't know if it is possible so I thought I'd ask. I think it would work if I had a keyboard hook that looked for the TAB or ESC key being pressed and then tested if the ALT or CTRL keys were pressed at the same time. Except I'm not sure how to test for ALT or CTRL. Is there an API call that would do this?
Posted on 2001-10-09 21:03:32 by Cintrifical
Here u have the code to check that keys ... You can find it in the FMacros Source, the file data.asm and the procedure "TypeText".

@@: invoke GetAsyncKeyState, VK_CONTROL ; Check if user has released Control Key...
ror eax, 16
or ax, ax ; If AX is not Zero, Control is still pressed,
jnz @B ; so let's check again...
invoke GetAsyncKeyState, VK_SHIFT ; Check if user has released Shift Key...
ror eax, 16
or ax, ax
jnz @B
invoke GetAsyncKeyState, VK_MENU ; Check if user has released Alt Key...
ror eax, 16
or ax, ax
jnz @B


Now, if u wanna catch CTRL+ALT+DEL there are a pair of simple tricks to achieve that in a simple way, but I won't credit myself for that, I'll give you two .htmls that I took from Iczelion's Site. Read the Question 12 from the Win32Api1.html that you can find in the .zip file and you'll find the answer to your question.
By the way, read both html's since they have a bunch of good fast tricks to do a lot of things... :) This html's will save u a lot of time for doing that kinda things ... Good Luck with them !! :)
PS: if you find any bugs or any suggestions, addons or anything for the F-Macros program, please let me know.
Go ahead, download the .zip !! :)


-MagicMac. :alright:
Posted on 2001-10-09 23:20:30 by magicmac