I installed a keyboard hook; but for each key press, it seems to fire twice (I'm guessing responding to down/up state)
A bit of poking around, I discovered that the 3rd parameter is positve, then negative.
is this a valid use so my hook only processes once?
I found several posts here; but none seemed to address the double-calling; some use the 3rd parameter as a structure (I get invalid memory if I try to access the structure elements) others just ignore it.
Thanks
-j
Keyboard hooks; called twice?
Re: Keyboard hooks; called twice?
A program stripped to the bare minimum exhibiting some kind of behavior and subsequently a question from you about that behavior would help. 
"Have you tried turning it off and on again ?"
Re: Keyboard hooks; called twice?
Um, okluis wrote:A program stripped to the bare minimum exhibiting some kind of behavior and subsequently a question from you about that behavior would help.
Code: Select all
Procedure.l myKeyboardHook(nCode, wParam, lParam)-
MachineCode
- Addict

- Posts: 1482
- Joined: Tue Feb 22, 2011 1:16 pm
Re: Keyboard hooks; called twice?
How does that single line of code exhibit some kind of behavior with which we can work? We don't know what the third parameter is used for because we can't see the entire procedure, nor the context in which the procedure is called.
Microsoft Visual Basic only lasted 7 short years: 1991 to 1998.
PureBasic: Born in 1998 and still going strong to this very day!
PureBasic: Born in 1998 and still going strong to this very day!
Re: Keyboard hooks; called twice?
In the documentation for SetWindowsHookEx_() (which I guess you used, but I can only guess, because you didn't tell or show) there is a link to each type of hook procedure, explaining the parameters.
http://msdn.microsoft.com/en-us/library ... S.85).aspx
http://msdn.microsoft.com/en-us/library ... S.85).aspx
http://msdn.microsoft.com/en-us/library ... S.85).aspx
http://msdn.microsoft.com/en-us/library ... S.85).aspx
Re: Keyboard hooks; called twice?
You're right; I am sorry -- I thought I pasted both parts.
Here's the call to set the hook.
hhook = SetWindowsHookEx_(#WH_KEYBOARD, @myKeyboardHook(), hInstance, GetCurrentThreadId_())
Thank you for the links; I will read there instead.
Cheers
-j
Here's the call to set the hook.
hhook = SetWindowsHookEx_(#WH_KEYBOARD, @myKeyboardHook(), hInstance, GetCurrentThreadId_())
Thank you for the links; I will read there instead.
Cheers
-j
