I have an application that provides a simple keystroke record/playback
macro facility using WH_JOURNALRECORD and WH_JOURNALPLAYBACK hooks. The
app can save keystroke sequences to a file so that they can be reloaded
and played back at a later date. The record hook only handles keyboard
(keyup and keydown) messages, not mouse or any other messages, and only
from the same application.
I have some questions that go somewhat beyond what the SDK docs say ...
1. On playback, the hWnd in the EVENTMSG structure seems to be ignored
.. this is just as well as we may record a macro one day and play it
back another day in a different run of the app, where none of the
window handles from the original app will be valid. Is it safe to
assume that the hWnd is ignored or would I be better off setting it to
zero or -1 (or something)?
2. There's a potential problem if (say) CAPS LOCK is on when the macro
is recorded and off when it is played back. I'd like to capture the
CAPS (and other) LOCK state(s) when recording and force the same state
for playback ... what's the best way?
3. If a macro is played back on a PC with a different keyboard layout
from the one on which it was recorded the scan codes in the EVENTMSG
structure won't tally with the virtual key codes ... is this a problem?
It seems to me that when the macro is played back the application only
needs to look at the VK codes, and the scan codes may be ignored (I
haven't tested this yet). Ideally I'd like to be able to create
EVENTMSG structures with only the VK code (e.g. provide a macro editing
interface that dealt only in VK codes) ... is this possible, or does
the message loop that the keystrokes are played back into require the
4. Is there any more detailed documentation than is in the Platform SDK
documentation? It's really very sketchy.