I tried hooking a wnd proc of a window, when suddenly a wild variable appeared...
Ok, let me describe my problem a little bit more. I P/Invoked some functions to access C++ WinApi from C#. I wanted to copy some keystrokes from one window to another (aka dual boxing in WoW and other MMOs) The P/Invoking works just fine and I'm happy, but I'm confused what the variable dwExtraInfo
is for. The documentation on this field just repeats what the name itself says already...
Here is the definition: http://msdn.microsoft.com/en-us/library/windows/desktop/ms644967(v=vs.85).aspx
Or for the lazy ones (I'm one of them too :P):
[StructLayout(LayoutKind.Sequential)]
public class KBDLLHOOKSTRUCT
{
public uint vkCode;
public uint scanCode;
public KBDLLHOOKSTRUCTFlags flags;
public uint time;
public UIntPtr dwExtraInfo;
}
When I want to send this data to a game (SendMessage with WPARAM set to WM_KEYDOWN
and WM_KEYUP
), I set vkCode to WPARAM and build my LPARAM from this structure. Is dwExtraInfo just the amount of keystrokes in one message?
For example, I hold down the w-key
for about 10 seconds, does it store the amount of keystrokes in one intervall before the next message will be sent?
This variable really confuses me...
It represents "extra" information that the developer can use when working with a LowLevelKeyboardProc
, for instance, to indicate a certain or special type of keyboard event (like an artificially generated keystroke). In a LowLevelKeyboardProc
, the lParam
is a pointer to a KBDLLHOOKSTRUCT
that holds the dwExtraInfo.
Here is a good example of it in use: https://web.archive.org/web/20170710091853/http://globalmousekeyhook.codeplex.com/discussions/286784
While dwExtraInfo
is meant to be a pointer, in that example they just set it to an arbitrary value 111
.
It is the exact same value as you see used in keybd_event(). Or the KEYBDINPUT structure used by SendInput(). Or what you get from GetMessageExtraInfo(). Which describes it:
Extra message information is an application- or driver-defined value associated with the current thread's message queue.
So as long as you don't add any extra info to a keyboard message that you generate with keybd_event() or SendInput(), or the driver doesn't add anything (the default keyboard driver doesn't), then this field is of no interest to you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With