trouble with "Windows Journal Hook"
-
I have read the MSDN document section about Journal Hook over and over again, still be confused with the following things. 1.Does the Journal Record Hook record the user actions( like mouse clicks or keyboard events ), then Journal Playback Hook replays the series of actions which the user has just performed? 2.The lParam of the JournalRecordProc is a pointer to a EVENTMSG, I can copy it to a buffer as the MSDN tells us to, but what are we supposed to do with these EVENTMSG buffer? 3.The lParam of the JournalPlaybackProc is also a pointer to a EVENTMSG, I think this EVENTMSG is one of the actions which the user has just performed, what should we do with it in order to replay the action?
-
I have read the MSDN document section about Journal Hook over and over again, still be confused with the following things. 1.Does the Journal Record Hook record the user actions( like mouse clicks or keyboard events ), then Journal Playback Hook replays the series of actions which the user has just performed? 2.The lParam of the JournalRecordProc is a pointer to a EVENTMSG, I can copy it to a buffer as the MSDN tells us to, but what are we supposed to do with these EVENTMSG buffer? 3.The lParam of the JournalPlaybackProc is also a pointer to a EVENTMSG, I think this EVENTMSG is one of the actions which the user has just performed, what should we do with it in order to replay the action?
During Journal Record, you need to make copies of the
EVENTMSG
structures passed inlParam
. You can do this by creating a vector orEVENTMSG
structures -std::vector<EVENTMSG> vEventMsgs;
Whenever the journal hook callback is called you can usestd::vector::push_back
to make copies of this structure. During playback, copy back the storedEVENTMSG
structures tolParam
. The return value from the journal playback callback must be the amount of time to wait till the next journal playback callback is called. You can calculate this from thetime
member of theEVENTMSG
structure. Take a look at this article to find out how its done - Writing a Macro Recorder/Player using Win32 Journal Hooks[^]«_Superman_» _I love work. It gives me something to do between weekends.